10
11
12
13
14
15
16
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
|
# File 'lib/shai/commands/config.rb', line 10
def self.included(base)
base.class_eval do
desc "config SUBCOMMAND", "Manage configuration metadata"
def config(subcommand = nil, *args)
case subcommand
when "show"
config_show
when "set"
config_set(args)
when nil
ui.error("Missing subcommand. Use `shai config show` or `shai config set`")
exit EXIT_INVALID_INPUT
else
ui.error("Unknown subcommand: #{subcommand}")
exit EXIT_INVALID_INPUT
end
end
desc "delete SLUG", "Delete a configuration"
def delete(slug)
require_auth!
unless ui.yes?("Are you sure you want to delete '#{slug}'? This cannot be undone.")
ui.info("Cancelled")
return
end
begin
ui.spinner("Deleting...") do
api.delete_configuration(slug)
end
ui.success("Configuration '#{slug}' deleted")
rescue NotFoundError
ui.error("Configuration '#{slug}' not found.")
exit EXIT_NOT_FOUND
rescue PermissionDeniedError
ui.error("You don't have permission to delete '#{slug}'.")
exit EXIT_PERMISSION_DENIED
rescue NetworkError => e
ui.error(e.message)
exit EXIT_NETWORK_ERROR
end
end
end
end
|