Class: Tracker::Cli
- Inherits:
-
Object
- Object
- Tracker::Cli
- Defined in:
- lib/tracker/cli.rb,
lib/tracker/cli/command.rb,
lib/tracker/cli/version.rb,
lib/tracker/cli/command/list.rb,
lib/tracker/cli/command/fetch.rb
Defined Under Namespace
Modules: Command
Constant Summary collapse
- VERSION =
"0.1.0"
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(argv) ⇒ Cli
constructor
A new instance of Cli.
- #validate_configuration! ⇒ Object
Constructor Details
#initialize(argv) ⇒ Cli
Returns a new instance of Cli.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/tracker/cli.rb', line 5 def initialize(argv) validate_configuration! arguments = OptionParser.parse!(argv) arguments[:cli] = self case arguments[:method] when :list then Command::List.new(**arguments) when :fetch then Command::Fetch.new(**arguments) end end |
Instance Method Details
#connection ⇒ Object
17 18 19 |
# File 'lib/tracker/cli.rb', line 17 def connection @connection ||= Client.new(Tracker.api_token) end |
#validate_configuration! ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/tracker/cli.rb', line 21 def validate_configuration! if Tracker.api_token.nil? error = "API Token missing. Find yours at https://www.pivotaltracker.com/profile and add: \n\napi_token: {{YOUR_TOKEN}}\n\n to ~/.tracker.config" end if Tracker.project.nil? error = "Project id is missing. Find the id in the url for the project and add: \n\nproject: {{YOUR_PROJECT_ID}}\n\n to ~/.tracker.config" end if error raise ArgumentError, error end end |