Class: OsUp::Cli::App

Inherits:
Object
  • Object
show all
Includes:
GLI::App
Defined in:
lib/osup/cli/app.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.getObject



7
8
9
10
11
# File 'lib/osup/cli/app.rb', line 7

def self.get
  cli = new
  cli.setup
  cli
end

.runObject



13
14
15
# File 'lib/osup/cli/app.rb', line 13

def self.run
  exit(get.run(ARGV))
end

Instance Method Details

#setupObject



17
18
19
20
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/osup/cli/app.rb', line 17

def setup
  Thread.abort_on_exception = true

  program_desc 'System upgrade manager for vpsAdminOS'
  version OsUp::VERSION
  subcommand_option_handling :normal
  preserve_argv true
  arguments :strict
  hide_commands_without_desc true

  desc 'Do not make any changes, just print what would happen'
  switch %i[n dry-run], negatable: false

  desc 'Print executed commands'
  switch %i[d debug], negatable: false

  desc 'Show status of all pools or a selected pool'
  arg_name '[pool]'
  command :status do |c|
    c.desc 'Do not show header'
    c.switch %i[H hide-header], negatable: false

    c.action(&Command.run(Main, :status))
  end

  desc 'Check status of all pools or a selected pool'
  arg_name '[pool]'
  command :check do |c|
    c.action(&Command.run(Main, :check))
  end

  desc 'Check flags for rollback to a specific version'
  arg_name '<pool> <version>'
  command 'check-rollback' do |c|
    c.action(&Command.run(Main, :check_rollback))
  end

  desc 'Initialize osup on selected pool'
  arg_name '<pool>'
  command :init do |c|
    c.desc 'Overwrite existing version file'
    c.switch %i[f force], negatable: false

    c.action(&Command.run(Main, :init))
  end

  desc 'Upgrade selected pool'
  arg_name '<pool> [version]'
  command :upgrade do |c|
    c.action(&Command.run(Main, :upgrade))
  end

  desc 'Upgrade all pools'
  arg_name '[version]'
  command 'upgrade-all' do |c|
    c.action(&Command.run(Main, :upgrade_all))
  end

  desc 'Rollback selected pool'
  arg_name '<pool> [version]'
  command :rollback do |c|
    c.action(&Command.run(Main, :rollback))
  end

  desc 'Rollback all pools'
  arg_name '[version]'
  command 'rollback-all' do |c|
    c.action(&Command.run(Main, :rollback_all))
  end

  command 'gen-completion' do |g|
    g.command :bash do |c|
      c.action(&Command.run(Main, :gen_bash_completion))
    end
  end

  # desc 'Execute migration' (do not uncomment this line to hide it from help)
  arg_name '<pool> <migration dirname> <action>'
  command :run do |c|
    c.action(&Command.run(Runner, :run))
  end
end