Class: CliTemplate::New
Class Method Summary
collapse
-
.cli_options ⇒ Object
Ugly, but when the class_option is only defined in the Thor::Group class it doesnt show up with cli-template new help :( If anyone knows how to fix this let me know. Also options from the cli can be pass through to here.
Instance Method Summary
collapse
Methods inherited from Sequence
source_root
Methods included from Helper
#project_class_name, #underscored_name
Class Method Details
.cli_options ⇒ Object
Ugly, but when the class_option is only defined in the Thor::Group class it doesnt show up with cli-template new help :( If anyone knows how to fix this let me know. Also options from the cli can be pass through to here
9
10
11
12
13
14
15
|
# File 'lib/cli-template/new.rb', line 9
def self.cli_options
[
[:repo, desc: "GitHub repo to use. Format: user/repo"],
[:force, type: :boolean, desc: "Bypass overwrite are you sure prompt for existing files."],
[:git, type: :boolean, default: true, desc: "Git initialize the project"],
]
end
|
Instance Method Details
#bundle_install ⇒ Object
33
34
35
36
37
|
# File 'lib/cli-template/new.rb', line 33
def bundle_install
Bundler.with_clean_env do
system("BUNDLE_IGNORE_CONFIG=1 bundle install")
end
end
|
#create_project ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/cli-template/new.rb', line 21
def create_project
options[:repo] ? clone_project : copy_project
destination_root = "#{Dir.pwd}/#{project_name}"
self.destination_root = destination_root
FileUtils.cd("#{Dir.pwd}/#{project_name}")
end
|
#git_init ⇒ Object
39
40
41
42
43
44
45
46
47
|
# File 'lib/cli-template/new.rb', line 39
def git_init
return if !options[:git]
return unless git_installed?
return if File.exist?(".git")
run("git init")
run("git add .")
run("git commit -m 'first commit'")
end
|
#make_executable ⇒ Object
29
30
31
|
# File 'lib/cli-template/new.rb', line 29
def make_executable
chmod("exe", 0755 & ~File.umask, verbose: false) if File.exist?("exe")
end
|
#user_message ⇒ Object
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
|
# File 'lib/cli-template/new.rb', line 49
def user_message
puts <<-EOL
#{"="*64}
Congrats 🎉 You have successfully created a CLI project.
Test the CLI:
cd #{project_name}
bundle
exe/#{project_name} hello # top-level commands
exe/#{project_name} sub:goodbye # sub commands
bundle exec rspec
To publish your CLI as a gem:
1. edit the #{project_name}.gemspec
2. edit lib/#{project_name}/version.rb
3. update the CHANGELOG.md
And run:
rake release
EOL
end
|