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.
-
#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
- #call(api_token: nil, per_page: DEFAULT_PAGE_SIZE, verbose: false, info: true) ⇒ Object
- #client ⇒ Object
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 |
#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 47 48 49 50 51 |
# 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 || determine_github_token self.per_page = per_page.to_i || DEFAULT_PAGE_SIZE if info begin print_userinfo rescue StandardError nil end end end |
#client ⇒ Object
53 54 55 |
# File 'lib/githuh/cli/commands/base.rb', line 53 def client @client ||= Octokit::Client.new(access_token: token) end |