Class: Aid::Scripts::New
Constant Summary
Constants included
from Colorize
Colorize::COLOR_CODES
Instance Attribute Summary
Attributes inherited from Aid::Script
#argv
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Aid::Script
#description, #exit_code, #exit_with_help!, #help, #initialize, name, run, #step, #system!
included
Methods included from Colorize
#colorize, included
Constructor Details
This class inherits a constructor from Aid::Script
Class Method Details
.description ⇒ Object
4
5
6
|
# File 'lib/aid/scripts/new.rb', line 4
def self.description
"Generates a new script in the aid directory"
end
|
.help ⇒ Object
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/aid/scripts/new.rb', line 8
def self.help
<<~HELP
Usage: aid new [script name]
Generates a new script file in the aid script directory.
Example:
#{colorize(:green, "$ aid new my-script-name")}
will generate a new script called my_script_name.rb
HELP
end
|
Instance Method Details
#run ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/aid/scripts/new.rb', line 21
def run
exit_with_help! unless script_name
check_for_aid_directory!
step "Creating #{output_path}" do
File.open(output_path, "wb") do |fp|
fp.write(template)
end
puts
print "Successfully created "
puts colorize(:green, output_path)
end
end
|