Function run_main

Source
pub async fn run_main(args: Vec<String>) -> Result<()>
Expand description

This is the backend entry point for console applications.

The idea here is that all functionality is implemented in Rust. However, passing command line arguments is done differently in Python, node.js, or Rust.

  • In python, the CLI arguments list is optionally passed to the binding’s cpp_linter.main() function (which wraps run_main()). If no args are passed, then cpp_linter.main() uses std::env::args without the leading path to the python interpreter removed.
  • In node.js, the process.argv array (without the leading path to the node interpreter removed) is passed from cli.js module to rust via index.node module’s main() (which wraps(run_main())).
  • In rust, the std::env::args is passed to run_main() in the binary source main.rs.

This is done because of the way the python entry point is invoked. If std::env::args is used instead of python’s sys.argv, then the list of strings includes the entry point alias (“path/to/cpp-linter.exe”). Thus, the parser in crate::cli will halt on an error because it is not configured to handle positional arguments.