Class: EasyCreds::ThorCLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/easy_creds/thor_cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


10
# File 'lib/easy_creds/thor_cli.rb', line 10

def self.exit_on_failure? = true

.start(given_args = ARGV, config = {}) ⇒ Object

No-args invocation → styled welcome instead of plain Thor help.



13
14
15
# File 'lib/easy_creds/thor_cli.rb', line 13

def self.start(given_args = ARGV, config = {})
  given_args.empty? ? new.send(:welcome) : super
end

Instance Method Details

#doctorObject



67
68
69
70
71
# File 'lib/easy_creds/thor_cli.rb', line 67

def doctor
  EasyCreds.load_global_config!
  ok = EasyCreds::Doctor.new(verbose: options[:verbose]).run
  exit 1 unless ok
end

#initObject



50
51
52
53
54
# File 'lib/easy_creds/thor_cli.rb', line 50

def init
  EasyCreds.configure { |c| c.global_dir = options[:'global-dir'] } if options[:'global-dir']
  prompt = build_prompt
  EasyCreds::Onboarding::GemSetup.run(prompt: prompt)
end

#installObject



74
75
76
77
78
79
80
81
# File 'lib/easy_creds/thor_cli.rb', line 74

def install
  project = EasyCreds::Project.detect(Dir.pwd)
  unless project.is_a?(EasyCreds::Project::Rails)
    puts EasyCreds::Theme.warn('Not a Rails project — nothing to install.')
    exit 3
  end
  EasyCreds::Installer.new(project.root).run
end

#onboardObject



59
60
61
62
63
# File 'lib/easy_creds/thor_cli.rb', line 59

def onboard
  EasyCreds.load_global_config!
  project = EasyCreds::Project.detect(Dir.pwd)
  EasyCreds::Onboarding::Runner.start(project: project, template: options[:template], force: options[:force])
end

#projectsObject



84
85
86
87
88
# File 'lib/easy_creds/thor_cli.rb', line 84

def projects
  EasyCreds.load_global_config!
  registry = Projects::Registry.load
  outside_picker_loop(registry)
end

#settingsObject



97
98
99
100
# File 'lib/easy_creds/thor_cli.rb', line 97

def settings
  EasyCreds.load_global_config!
  Views::SettingsMenu.run(build_prompt)
end

#sync(env = nil) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/easy_creds/thor_cli.rb', line 21

def sync(env = nil)
  EasyCreds.load_global_config!
  EasyCreds.ensure_default_template!
  check_first_run!

  EasyCreds.configure { |c| c.default_vault = options[:vault] } if options[:vault]

  registry = Projects::Registry.load
  project  = EasyCreds::Project.detect(Dir.pwd)

  if (known = registry.find_by_path(project.root))
    registry.touch(known)
    return EasyCreds::CLI.start(project: project, default_env: env)
  end

  if looks_like_project?(project) && !skip_register?
    result = Onboarding::RegisterPrompt.run(
      prompt: build_prompt, project: project, registry: registry
    )
    return if result == :quit

    return EasyCreds::CLI.start(project: project, default_env: env)
  end

  outside_picker_loop(registry)
end

#templatesObject



91
92
93
94
# File 'lib/easy_creds/thor_cli.rb', line 91

def templates
  EasyCreds.load_global_config!
  Views::TemplatesMenu.run(build_prompt)
end

#treeObject



103
104
105
# File 'lib/easy_creds/thor_cli.rb', line 103

def tree
  render_command_tree
end

#versionObject



108
109
110
# File 'lib/easy_creds/thor_cli.rb', line 108

def version
  beastmode_version
end