I'm reading the code of Substrate Node Template, trying to get a deeper understanding of the implementation of it. However, I stuck when I tried to find out how the node deals with command line arguments, such as --dev.

From what I have learned from the codes, I believe that the SubstrateCli::from_iter function is responsible for parsing command line arguments, and the program crashes at the let matches = app.try_get_matches_from(iter).unwrap_or_else(|e| e.exit()); statement if I enter a incorrect cli argument(--devx, for instance). But how does the program know that --devx is incorrect while --dev is the correct one?

1 Answer 1


I think this is a built-in feature of clap instead of Substrate.


  • And specifically, Substrate uses clap's derive macros (formerly known as structopt) Commented Jan 9 at 5:28
  • Could you please tell me if --dev is a built-in feature of clap? Also, is there a way for the node to determine if the user has provided this flag in the CLI? Commented Jan 10 at 6:05
  • First question clap is a cli framework, --dev is a custom flag that they use this framework to build. Second question github.com/substrate-developer-hub/substrate-node-template/blob/….
    – AurevoirXavier
    Commented Jan 10 at 6:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.