Class: GemContribute::CLI::Init
- Inherits:
-
Object
- Object
- GemContribute::CLI::Init
- Defined in:
- lib/gem_contribute/cli/init.rb
Overview
‘gem-contribute init` — interactive one-time setup. Writes the user’s ‘clone_root` to ~/.config/gem-contribute/config.yml and, if no GitHub token is cached, offers to run `auth login`.
Without init, ‘fix` errors with a hint to run init. The point is to avoid creating directories or assuming auth without explicit consent.
Constant Summary collapse
- USAGE =
<<~USAGE Usage: gem-contribute init Interactively set the directory where forks are cloned (clone_root), then offer to authenticate with GitHub if you haven't already. Re-run any time to change. USAGE
- DEFAULT_SUGGESTION =
"~/code/oss"- AUTH_HOST =
"github.com"
Instance Method Summary collapse
-
#initialize(stdout: $stdout, stderr: $stderr, config: GemContribute::Config.new, store: GemContribute::TokenStore.new, auth: nil, gets: -> { $stdin.gets }) ⇒ Init
constructor
A new instance of Init.
- #run(argv) ⇒ Object
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr, config: GemContribute::Config.new, store: GemContribute::TokenStore.new, auth: nil, gets: -> { $stdin.gets }) ⇒ Init
Returns a new instance of Init.
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gem_contribute/cli/init.rb', line 23 def initialize(stdout: $stdout, stderr: $stderr, config: GemContribute::Config.new, store: GemContribute::TokenStore.new, auth: nil, gets: -> { $stdin.gets }) @stdout = stdout @stderr = stderr @config = config @store = store @auth = auth || GemContribute::CLI::Auth.new(stdout: stdout, stderr: stderr, store: store) @gets = gets end |
Instance Method Details
#run(argv) ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/gem_contribute/cli/init.rb', line 36 def run(argv) return print_usage if %w[help -h --help].include?(argv.first) prompt_clone_root maybe_authenticate 0 end |