diff --git a/src/cmd/sdf_main.cc b/src/cmd/sdf_main.cc index b9d38a4ff..5ff3a433a 100644 --- a/src/cmd/sdf_main.cc +++ b/src/cmd/sdf_main.cc @@ -114,12 +114,12 @@ void addSdfFlags(CLI::App &_app) auto filepathOpt = _app.add_option("filepath", opt->filepath, "Path to an SDFormat file."); - _app.add_option("-i,--preserve-includes", opt->preserveIncludes, + _app.add_flag("-i,--preserve-includes", opt->preserveIncludes, "Preserve included tags when printing converted arg (does " "not preserve merge-includes)."); - _app.add_option("--degrees", opt->degrees, + _app.add_flag("--degrees", opt->degrees, "Printed pose rotations are will be in degrees."); - _app.add_option("--expand-auto-inertials", opt->expandAutoInertials, + _app.add_flag("--expand-auto-inertials", opt->expandAutoInertials, "Auto-computed inertial values will be printed."); _app.add_option("--precision", opt->precision, "Set the output stream precision for floating point " @@ -146,7 +146,9 @@ void addSdfFlags(CLI::App &_app) opt->version = _version; }, "Print the aggregated SDFormat spec description. Latest version (" - SDF_PROTOCOL_VERSION ")"); + SDF_PROTOCOL_VERSION ")") + ->expected(0, 1) + ->default_val(SDF_PROTOCOL_VERSION); command->add_option_function("-g,--graph", [opt](const std::string &_graphType){ diff --git a/src/gz_TEST.cc b/src/gz_TEST.cc index 02ad926ad..dc54a45d2 100644 --- a/src/gz_TEST.cc +++ b/src/gz_TEST.cc @@ -1066,8 +1066,7 @@ TEST(describe, SDF) { // Get the description std::string output = - custom_exec_str(GzCommand() + " sdf -d " + - SDF_PROTOCOL_VERSION + SdfVersion()); + custom_exec_str(GzCommand() + " sdf -d " + SdfVersion()); EXPECT_FALSE(output.empty()); // The first line should start with the following text. @@ -1119,7 +1118,7 @@ TEST(print_rotations_in_degrees, SDF) // Printing with in_degrees output = custom_exec_str( - GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1" + GzCommand() + " sdf -p --precision 6 " + path + " --degrees " + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, @@ -1187,7 +1186,7 @@ TEST(print_rotations_in_radians, SDF) // Printing with in_degrees output = custom_exec_str( - GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1" + GzCommand() + " sdf -p --precision 6 " + path + " --degrees " + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, @@ -1256,7 +1255,7 @@ TEST(print_rotations_in_quaternions, SDF) // Printing with in_degrees output = custom_exec_str( - GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1" + GzCommand() + " sdf -p --precision 6 " + path + " --degrees " + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, @@ -1327,7 +1326,7 @@ TEST(print_includes_rotations_in_degrees, SDF) // Printing with in_degrees output = custom_exec_str( - GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1" + GzCommand() + " sdf -p --precision 6 " + path + " --degrees " + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, @@ -1398,7 +1397,7 @@ TEST(print_includes_rotations_in_radians, SDF) // Printing with in_degrees output = custom_exec_str( - GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1" + GzCommand() + " sdf -p --precision 6 " + path + " --degrees " + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, @@ -1470,7 +1469,7 @@ TEST(print_includes_rotations_in_quaternions, SDF) // Printing with in_degrees output = custom_exec_str( - GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1" + GzCommand() + " sdf -p --precision 6 " + path + " --degrees " + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, @@ -1541,7 +1540,7 @@ TEST(print_rotations_in_unnormalized_degrees, SDF) // Printing with in_degrees output = custom_exec_str( - GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1" + GzCommand() + " sdf -p --precision 6 " + path + " --degrees " + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, @@ -1609,7 +1608,7 @@ TEST(print_rotations_in_unnormalized_radians, SDF) // Printing with in_degrees output = custom_exec_str( - GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1" + GzCommand() + " sdf -p --precision 6 " + path + " --degrees " + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, @@ -1668,18 +1667,18 @@ TEST(shuffled_cmd_flags, SDF) const std::string path = sdf::testing::TestFile("sdf", "rotations_in_unnormalized_radians.sdf"); - // -p PATH --degrees ARG + // -p PATH --degrees std::string output = custom_exec_str( - GzCommand() + " sdf -p --precision 6 " + path + " --degrees 1" + GzCommand() + " sdf -p --precision 6 " + path + " --degrees " + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, "" "1 2 3 30.009 44.9915 -60.009"); - // --degrees ARG -p PATH + // --degrees -p PATH output = custom_exec_str( - GzCommand() + " sdf --degrees 1 -p --precision 6 " + path + SdfVersion()); + GzCommand() + " sdf --degrees -p --precision 6 " + path + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, "" @@ -1749,7 +1748,7 @@ TEST(print_auto_inertial, SDF) // expect and elements std::string output = custom_exec_str( GzCommand() + " sdf -p " + path + - " --expand-auto-inertials 1 " + + " --expand-auto-inertials " + SdfVersion()); ASSERT_FALSE(output.empty()); EXPECT_PRED2(sdf::testing::contains, output, "");