35
35
36
36
#include " linenoise.hpp"
37
37
38
+ #include " brlcad_ident.h"
38
39
#include " bu.h"
39
40
#include " bv.h"
40
41
@@ -752,11 +753,14 @@ main(int argc, const char **argv)
752
753
753
754
/* Options */
754
755
int print_help = 0 ;
756
+ int report_versions = 0 ;
755
757
int new_cmd_forms = 0 ;
756
- struct bu_opt_desc d[3 ];
757
- BU_OPT (d[0 ], " h" , " help" , " " , NULL , &print_help, " print help and exit" );
758
- BU_OPT (d[1 ], " " , " new-cmds" , " " , NULL , &new_cmd_forms, " use new (qged style) commands" );
759
- BU_OPT_NULL (d[2 ]);
758
+ struct bu_opt_desc d[5 ];
759
+ BU_OPT (d[0 ], " h" , " help" , " " , NULL , &print_help, " print help and exit" );
760
+ BU_OPT (d[1 ], " ?" , " " , " " , NULL , &print_help, " " );
761
+ BU_OPT (d[2 ], " v" , " version" , " " , NULL , &report_versions, " Report BRL-CAD and library versions, then exit" );
762
+ BU_OPT (d[3 ], " " , " new-cmds" , " " , NULL , &new_cmd_forms, " use new (qged style) commands" );
763
+ BU_OPT_NULL (d[4 ]);
760
764
761
765
/* Parse options, fail if anything goes wrong */
762
766
struct bu_vls opt_msg = BU_VLS_INIT_ZERO;
@@ -771,9 +775,27 @@ main(int argc, const char **argv)
771
775
if (print_help) {
772
776
struct bu_vls msg = BU_VLS_INIT_ZERO;
773
777
const char *help = bu_opt_describe (d, NULL );
774
- bu_vls_sprintf (&msg, " Usage: 'gsh [options] model.g'\n\n Options:\n %s\n " , help);
778
+ bu_vls_sprintf (&msg, " Usage: 'gsh [options] model.g' [args] \n\n Options:\n %s\n " , help);
775
779
bu_free ((char *)help, " done with help string" );
776
- fputs (bu_vls_addr (&msg), stderr);
780
+ fputs (bu_vls_cstr (&msg), stderr);
781
+ bu_vls_free (&msg);
782
+ bu_exit (EXIT_SUCCESS, NULL );
783
+ }
784
+
785
+ /* If we're just reporting BRL-CAD and lib versions, do that */
786
+ if (report_versions) {
787
+ struct bu_vls msg = BU_VLS_INIT_ZERO;
788
+ bu_vls_sprintf (&msg, " %s%s%s%s%s" ,
789
+ brlcad_ident (" Geometry Shell (gsh)" ),
790
+ bu_version (),
791
+ bn_version (),
792
+ rt_version (),
793
+ ged_version ());
794
+ #ifdef USE_DM
795
+ bu_vls_printf (&msg, " %s" , dm_version ());
796
+ #endif
797
+ bu_vls_printf (&msg, " \n " );
798
+ std::cout << bu_vls_cstr (&msg);
777
799
bu_vls_free (&msg);
778
800
bu_exit (EXIT_SUCCESS, NULL );
779
801
}
@@ -874,7 +896,7 @@ main(int argc, const char **argv)
874
896
}
875
897
}
876
898
877
- return BRLCAD_OK ;
899
+ return EXIT_SUCCESS ;
878
900
}
879
901
880
902
// Local Variables:
0 commit comments