1

I am trying to get commands and flags to work in Dart, but I can't seem to figure out how to get the input from the user when running the command. I have the args package, and I am able to get it to work with basic things, like flags (-a, --help, etc), but I would like the user to be able to type a command, for example, git commit -m "hello", but I can not figure out how to get the last part of the command to work, with the custom input. How is it done? Are there any examples?

1 Answer 1

3

The command line arguments are available as a list of strings passed to the main function.

void main(List<String> args) { ... }

You can parse them directly from there using your own code, write your own general flag parser, or you can use the existing args package, which comes with documentation saying how to use it.

Most people use the args package.

Sign up to request clarification or add additional context in comments.

2 Comments

But when use dart run can not pass the arguments like as --help: dart run --help call the dart help, instead of the help of project.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.