@@ -5,10 +5,10 @@ module Geode::Commands
55
66 add_command List .new
77 add_command Add .new
8- # add_command Info.new
8+ add_command Info .new
99 # add_command Create.new
1010 # add_command Test.new
11- # add_command Remove.new
11+ add_command Remove .new
1212 end
1313
1414 def run (arguments : Cling ::Arguments , options : Cling ::Options ) : Nil
@@ -89,6 +89,56 @@ module Geode::Commands
8989 end
9090 end
9191
92+ class Info < Base
93+ def setup : Nil
94+ @name = " info"
95+
96+ add_argument " name" , required: true
97+ end
98+
99+ def run (arguments : Cling ::Arguments , options : Cling ::Options ) : Nil
100+ name = arguments.get(" name" ).as_s
101+ unless Geode ::Template .exists?(name)
102+ error " Template '#{ name } ' does not exist"
103+ exit_program
104+ end
105+
106+ template = Geode ::Template .load name
107+ stdout << " name: " .colorize.bold << template.name << '\n'
108+ stdout << " summary: " .colorize.bold << template.summary << " \n\n "
109+ stdout << " author: " .colorize.bold << template.author << '\n'
110+ stdout << " version: " .colorize.bold << template.version << '\n'
111+ stdout << " source: " .colorize.bold << (template.source || " (unknown)" .colorize.light_gray) << '\n'
112+ stdout << " files:" .colorize.bold
113+
114+ if template.files.empty?
115+ stdout << " none\n "
116+ else
117+ stdout << '\n'
118+ template.files.join(stdout) { |e , i | i << " • " << e << '\n' }
119+ end
120+ end
121+ end
122+
123+ class Remove < Base
124+ def setup : Nil
125+ @name = " remove"
126+
127+ add_argument " name" , required: true
128+ end
129+
130+ def run (arguments : Cling ::Arguments , options : Cling ::Options ) : Nil
131+ name = arguments.get(" name" ).as_s
132+
133+ if Geode ::Template .remove name
134+ success " Removed template '#{ name } '"
135+ else
136+ error " Template '#{ name } ' does not exist"
137+ exit_program
138+ end
139+ end
140+ end
141+
92142 class Create < Base
93143 private COMMAND = {% if flag?(:darwin ) % }" Cmd" {% else % }" Ctrl" {% end % }
94144 private CHAR = {% if flag?(:darwin ) % }" Q" {% else % }" C" {% end % }
0 commit comments