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.
Prompt input/output goes through ‘TTY::Prompt` (per ADR-0012 Phase 2, commit #31). The injected `prompt:` keyword lets tests pass a `TTY::Prompt.new(input:, output:)` with StringIO streams.
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, output: nil, config: GemContribute::Config.new, store: GemContribute::TokenStore.new, auth: nil, prompt: nil) ⇒ Init
constructor
A new instance of Init.
- #run(argv) ⇒ Object
Constructor Details
#initialize(stdout: $stdout, stderr: $stderr, output: nil, config: GemContribute::Config.new, store: GemContribute::TokenStore.new, auth: nil, prompt: nil) ⇒ Init
Returns a new instance of Init.
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/gem_contribute/cli/init.rb', line 29 def initialize(stdout: $stdout, stderr: $stderr, output: nil, config: GemContribute::Config.new, store: GemContribute::TokenStore.new, auth: nil, prompt: nil) @output = output || Output::Standard.new(out: stdout, err: stderr) @config = config @store = store @auth = auth || GemContribute::CLI::Auth.new(output: @output, store: store) @prompt = prompt || TTY::Prompt.new end |
Instance Method Details
#run(argv) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/gem_contribute/cli/init.rb', line 41 def run(argv) return print_usage if %w[help -h --help].include?(argv.first) prompt_clone_root maybe_authenticate 0 end |