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

Negative values for arguments not parsed #15

Open
n7st opened this issue Oct 11, 2019 · 0 comments
Open

Negative values for arguments not parsed #15

n7st opened this issue Oct 11, 2019 · 0 comments

Comments

@n7st
Copy link

n7st commented Oct 11, 2019

option :lon, help: "The venue's longitude", type: :float
% mix venue -v add 'Temple of Boom' --lat 53.8020657 --lon -1.5319708
No argument provided for 'lon'
% mix venue -v add 'Temple of Boom' --lat 53.8020657 --lon '-1.5319708'
No argument provided for 'lon'

Full script:

defmodule BandTracker.Venue do
  use ExCLI.DSL, mix_task: :venue                                                                                    
                             
  name "BandTracker.Venue"
  description "Venue operations"                          

  option :verbose, count: true, aliases: [:v]

  command :add do
    aliases [:a]
    description "Add a new venue"

    argument :name, help: "The venue's name"
    option :lat, help: "The venue's latitude", type: :float
    option :lon, help: "The venue's longitude", type: :float

    run context do
      if context.verbose > 0 do
        IO.puts("Adding new venue...")
      end

      name = context[:name]
      lat = context[:lat]
      lon = context[:lon]

      IO.write("Name: #{name}, latitude: #{lat}, longitude: #{lon}")
    end
  end
end
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

1 participant