Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using optarg to implement a simple cli #6

Open
pitosalas opened this issue Oct 24, 2018 · 1 comment
Open

Using optarg to implement a simple cli #6

pitosalas opened this issue Oct 24, 2018 · 1 comment

Comments

@pitosalas
Copy link

As an experiment... But it's not clear to me how I correctly bring in the ARGC and ARGV from the command line into the option parsing.

Or do I totally misunderstand what I am doing? (I am an experienced programmer by the way.)

@mosop
Copy link
Owner

mosop commented Oct 24, 2018

Hi :) You can use the ARGV variable like this:

main.cr:

require "optarg"

class Model < Optarg::Model
  arg "foo"
end

result = Model.parse(ARGV)
puts result.foo

in your terminal:

crystal main.cr -- ":)"

output:

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants