-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsgm
executable file
·84 lines (65 loc) · 2.5 KB
/
sgm
1
2
3
4
5
6
7
8
9
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
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
#!/usr/bin/env ruby
require "thor"
require "tty-table"
require "io/console"
require "yaml"
require_relative "./title-printer"
require_relative "./get-releases"
require_relative "./modulo-download"
require_relative "./modulo-version"
require_relative "./new-module"
PROMPT = "sgm"
SPINNER = Spinner.new
class Sigma < Thor
desc "new <module>", "create a new module with the default module configuration"
long_desc <<-LONGDESC
> #{PROMPT} new <name> - will create a new module with the default module project inititialized.
It takes one parameter, the name of the module.
The module folder created will be called <name>Module by convention
If the name is not provided, the module will be name 'NewModule'
LONGDESC
def new(name="New")
new_module(name[0].upcase + name[1..-1])
end
option :modulo, aliases: "-m", banner:"version", desc: "Use this flag to install modulo's server"
desc "install <module>", "install a module or a Modulo server"
long_desc <<-LONGDESC
> #{PROMPT} install <name> - will install a module.
It takes one parameter, the name of the module.
The name of the module must be provided to the command.
> #{PROMPT} install -modulo - will install a Modulo server on the current repertory.
It takes no parameter and it will let you choose the version of the Modulo server to install.
> #{PROMPT} install -modulo <version> - will install a Modulo server on the current repertory with the selected version.
LONGDESC
def install()
if options[:modulo]
download_modulo(options[:modulo])
else
puts "Installing module #{name}"
end
end
option :modulo, aliases: "-m", banner:"", desc: "Use this flag to print the version available for modulo"
desc "version", "print the version of SigmaCLI or the version available of Modulo with the flag -m"
def version
if options[:modulo]
print_modulo_version
else
print_title
yml = YAML.load_file(File.join(File.dirname(__FILE__), "./sigma.yml"))
puts "SigmaCLI : " + yml["version"]
end
end
end
class Thor
module Shell
class Basic
def print_wrapped(message, options = {})
stdout.puts message
end
end
end
end
if ARGV.empty?
print_title
end
Sigma.start(ARGV)