##// END OF EJS Templates
rhg: consistently use the command name given in clap::command!(<...>) macro...
rhg: consistently use the command name given in clap::command!(<...>) macro Before this patch there are 2 things the user controls: 1. the module/command name, specified in subcommand! macro 2. the command name, specified in clap::command! macro If these are out of sync, we get no compile error or a clear runtime error, but instead a confusing behavior where command line parser parses one thing, but running it doesn't work. This commit makes the clap::command! macro the sole authority determining the command name, so we don't have to worry about this weird behavior any more. It also makes it easy to validate agreement between (1) and (2) if we want it, but I didn't add the check because I'm not sure people necessarily want it.

File last commit:

r46195:426294d0 default
r53420:021c1b16 default
Show More
main.rs
39 lines | 1.4 KiB | application/rls-services+xml | RustLexer
use pyembed::MainPythonInterpreter;
// Include an auto-generated file containing the default
// `pyembed::PythonConfig` derived by the PyOxidizer configuration file.
//
// If you do not want to use PyOxidizer to generate this file, simply
// remove this line and instantiate your own instance of
// `pyembed::PythonConfig`.
include!(env!("PYOXIDIZER_DEFAULT_PYTHON_CONFIG_RS"));
fn main() {
// The following code is in a block so the MainPythonInterpreter is
// destroyed in an orderly manner, before process exit.
let code = {
// Load the default Python configuration as derived by the PyOxidizer
// config file used at build time.
let config = default_python_config();
// Construct a new Python interpreter using that config, handling any
// errors from construction.
match MainPythonInterpreter::new(config) {
Ok(mut interp) => {
// And run it using the default run configuration as specified
// by the configuration. If an uncaught Python
// exception is raised, handle it.
// This includes the special SystemExit, which is a request to
// terminate the process.
interp.run_as_main()
}
Err(msg) => {
eprintln!("{}", msg);
1
}
}
};
// And exit the process according to code execution results.
std::process::exit(code);
}