rust/hgcli/src/main.rs
changeset 45620 426294d06ddc
parent 44729 26ce8e751503
equal deleted inserted replaced
45619:e8078af6af30 45620:426294d06ddc
     7 // remove this line and instantiate your own instance of
     7 // remove this line and instantiate your own instance of
     8 // `pyembed::PythonConfig`.
     8 // `pyembed::PythonConfig`.
     9 include!(env!("PYOXIDIZER_DEFAULT_PYTHON_CONFIG_RS"));
     9 include!(env!("PYOXIDIZER_DEFAULT_PYTHON_CONFIG_RS"));
    10 
    10 
    11 fn main() {
    11 fn main() {
    12     // The following code is in a block so the MainPythonInterpreter is destroyed in an
    12     // The following code is in a block so the MainPythonInterpreter is
    13     // orderly manner, before process exit.
    13     // destroyed in an orderly manner, before process exit.
    14     let code = {
    14     let code = {
    15         // Load the default Python configuration as derived by the PyOxidizer config
    15         // Load the default Python configuration as derived by the PyOxidizer
    16         // file used at build time.
    16         // config file used at build time.
    17         let config = default_python_config();
    17         let config = default_python_config();
    18 
    18 
    19         // Construct a new Python interpreter using that config, handling any errors
    19         // Construct a new Python interpreter using that config, handling any
    20         // from construction.
    20         // errors from construction.
    21         match MainPythonInterpreter::new(config) {
    21         match MainPythonInterpreter::new(config) {
    22             Ok(mut interp) => {
    22             Ok(mut interp) => {
    23                 // And run it using the default run configuration as specified by the
    23                 // And run it using the default run configuration as specified
    24                 // configuration. If an uncaught Python exception is raised, handle it.
    24                 // by the configuration. If an uncaught Python
    25                 // This includes the special SystemExit, which is a request to terminate the
    25                 // exception is raised, handle it.
    26                 // process.
    26                 // This includes the special SystemExit, which is a request to
       
    27                 // terminate the process.
    27                 interp.run_as_main()
    28                 interp.run_as_main()
    28             }
    29             }
    29             Err(msg) => {
    30             Err(msg) => {
    30                 eprintln!("{}", msg);
    31                 eprintln!("{}", msg);
    31                 1
    32                 1