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 wrapsrun_main()
). If no args are passed, thencpp_linter.main()
usesstd::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 fromcli.js
module to rust viaindex.node
module’smain()
(which wraps(run_main()
)). - In rust, the
std::env::args
is passed torun_main()
in the binary sourcemain.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.