1010from ._version import VERSION
1111
1212
13+ def arg_resolved_path (arg : str ) -> Path :
14+ return Path (arg ).resolve ()
15+
16+
1317def _create_parser () -> argparse .ArgumentParser :
1418 cli = argparse .ArgumentParser (description = "Debmagic" )
1519 sp = cli .add_subparsers (dest = "operation" )
@@ -19,31 +23,27 @@ def _create_parser() -> argparse.ArgumentParser:
1923 sp .add_parser ("version" , help = "Print the version information and exit" )
2024
2125 common_cli = get_config_argparser ()
22- common_cli .add_argument ("-c" , "--config" , type = Path , help = "Path to a config file" )
26+ common_cli .add_argument ("-c" , "--config" , type = arg_resolved_path , help = "Path to a config file" )
2327
2428 build_cli = sp .add_parser (
2529 "build" , parents = [common_cli ], help = "Build a debian package with the selected containerization driver"
2630 )
2731 build_cli .add_argument ("--driver" , choices = SUPPORTED_BUILD_DRIVERS , required = True )
28- build_cli .add_argument ("-s" , "--source-dir" , type = Path , default = Path .cwd ())
29- build_cli .add_argument ("-o" , "--output-dir" , type = Path , default = Path .cwd ())
32+ build_cli .add_argument ("-s" , "--source-dir" , type = arg_resolved_path , default = Path .cwd ())
33+ build_cli .add_argument ("-o" , "--output-dir" , type = arg_resolved_path , default = Path .cwd ())
3034
3135 sp .add_parser ("check" , parents = [common_cli ], help = "Run linters (e.g. lintian)" )
3236
3337 shell_cli = sp .add_parser ("shell" , parents = [common_cli ], help = "Attach a shell to a running debmagic build" )
34- shell_cli .add_argument ("-s" , "--source-dir" , type = Path , default = Path .cwd ())
38+ shell_cli .add_argument ("-s" , "--source-dir" , type = arg_resolved_path , default = Path .cwd ())
3539
3640 sp .add_parser ("test" , parents = [common_cli ], help = "Run package tests" )
3741 return cli
3842
3943
4044def main (passed_args : Sequence [str ] | None = None ):
4145 cli = _create_parser ()
42- args , unknown_args = cli .parse_known_args (passed_args )
43-
44- if len (unknown_args ) > 0 and args .operation != "build" :
45- # TODO: proper validation and printout -> maybe differentiate between build subcommand and others???
46- raise RuntimeError ("unknown arguments passed" )
46+ args = cli .parse_args (passed_args )
4747
4848 config_file_paths : list [Path ] = []
4949 if args .config :
0 commit comments