Class: Githuh::CLI::Commands::Base
- Inherits:
-
Dry::CLI::Command
- Object
- Dry::CLI::Command
- Githuh::CLI::Commands::Base
- Extended by:
- Forwardable
- Defined in:
- lib/githuh/cli/commands/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#box ⇒ Object
Returns the value of attribute box.
-
#client ⇒ Object
Returns the value of attribute client.
-
#context ⇒ Object
Returns the value of attribute context.
-
#info ⇒ Object
Returns the value of attribute info.
-
#per_page ⇒ Object
Returns the value of attribute per_page.
-
#token ⇒ Object
Returns the value of attribute token.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#box ⇒ Object
Returns the value of attribute box.
31 32 33 |
# File 'lib/githuh/cli/commands/base.rb', line 31 def box @box end |
#client ⇒ Object
Returns the value of attribute client.
31 32 33 |
# File 'lib/githuh/cli/commands/base.rb', line 31 def client @client end |
#context ⇒ Object
Returns the value of attribute context.
31 32 33 |
# File 'lib/githuh/cli/commands/base.rb', line 31 def context @context end |
#info ⇒ Object
Returns the value of attribute info.
31 32 33 |
# File 'lib/githuh/cli/commands/base.rb', line 31 def info @info end |
#per_page ⇒ Object
Returns the value of attribute per_page.
31 32 33 |
# File 'lib/githuh/cli/commands/base.rb', line 31 def per_page @per_page end |
#token ⇒ Object
Returns the value of attribute token.
31 32 33 |
# File 'lib/githuh/cli/commands/base.rb', line 31 def token @token end |
#verbose ⇒ Object
Returns the value of attribute verbose.
31 32 33 |
# File 'lib/githuh/cli/commands/base.rb', line 31 def verbose @verbose end |
Class Method Details
.inherited(base) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/githuh/cli/commands/base.rb', line 20 def inherited(base) super base.instance_eval do option :api_token, required: false, desc: "Github API token; if not given, user.token is read from ~/.gitconfig" option :per_page, required: false, default: DEFAULT_PAGE_SIZE, desc: "Pagination page size for Github API" option :info, type: :boolean, default: true, desc: 'Print UI elements, like a the progress bar' option :verbose, type: :boolean, default: false, desc: 'Print additional debugging info' end end |
Instance Method Details
#call(api_token: nil, per_page: DEFAULT_PAGE_SIZE, verbose: false, info: true) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/githuh/cli/commands/base.rb', line 33 def call(api_token: nil, per_page: DEFAULT_PAGE_SIZE, verbose: false, info: true) self.context = Githuh self.verbose = verbose self.info = info self.token = api_token || token_from_gitconfig self.per_page = per_page.to_i || DEFAULT_PAGE_SIZE self.client = Octokit::Client.new(access_token: token) print_userinfo if info end |