File tree Expand file tree Collapse file tree
lib/rust/mmcamerasolve-bin/src Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1919//
2020//! CLI argument parsing without external dependencies.
2121
22+ use std:: env;
23+
2224use crate :: parser;
2325
2426use crate :: defaults:: DEFAULT_FILM_BACK_HEIGHT_MM ;
@@ -182,12 +184,30 @@ impl Default for CliArgs {
182184 }
183185}
184186
187+ fn default_executable_file_name ( ) -> & ' static str {
188+ match env:: consts:: OS {
189+ "windows" => "mmcamerasolve.exe" ,
190+ _ => "mmcamerasolve" ,
191+ }
192+ }
193+
194+ fn current_executable_file_name ( ) -> String {
195+ match env:: current_exe ( ) {
196+ Ok ( exe_path) => match exe_path. file_name ( ) {
197+ Some ( exe_file_name) => exe_file_name. to_string_lossy ( ) . to_string ( ) ,
198+ None => default_executable_file_name ( ) . to_string ( ) ,
199+ } ,
200+ Err ( _) => default_executable_file_name ( ) . to_string ( ) ,
201+ }
202+ }
203+
185204pub fn print_help ( ) {
205+ let executable_name = current_executable_file_name ( ) ;
186206 println ! (
187207 "mmSolver Camera Solver - Structure from Motion camera solver.
188208
189209USAGE:
190- mmsfm <UV_FILE> [OPTIONS]
210+ {executable_name} <UV_FILE> [OPTIONS]
191211
192212ARGUMENTS:
193213 <UV_FILE> Path to UV markers file (.uv)
@@ -244,7 +264,8 @@ HELP:
244264}
245265
246266pub fn print_version ( ) {
247- println ! ( "mmsfm {}" , env!( "CARGO_PKG_VERSION" ) ) ;
267+ let executable_name = current_executable_file_name ( ) ;
268+ println ! ( "{executable_name} {}" , env!( "CARGO_PKG_VERSION" ) ) ;
248269}
249270
250271macro_rules! try_parse {
You can’t perform that action at this time.
0 commit comments