-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CLI config overrides #126
Changes from 7 commits
9818d2a
a092524
1cf1e17
52469ff
fdc5549
9b2ce8d
0f9b24c
62631e6
ae45ca3
c8464ef
83b3edd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,11 +2,12 @@ module Liftoff | |
class CLI | ||
def initialize(argv) | ||
@argv = argv | ||
@options = {} | ||
end | ||
|
||
def run | ||
parse_command_line_options | ||
LaunchPad.new.liftoff | ||
LaunchPad.new.liftoff @options | ||
end | ||
|
||
private | ||
|
@@ -17,7 +18,7 @@ def parse_command_line_options | |
|
||
def global_options | ||
OptionParser.new do |opts| | ||
opts.banner = 'usage: liftoff [-v | --version] [-h | --help]' | ||
opts.banner = 'usage: liftoff [-v | --version] [-h | --help] [config options]' | ||
|
||
opts.on('-v', '--version', 'Display the version and exit') do | ||
puts "Version: #{Liftoff::VERSION}" | ||
|
@@ -28,6 +29,44 @@ def global_options | |
puts opts | ||
exit | ||
end | ||
|
||
# Boolean Options | ||
|
||
opts.on('--[no-]cocoapods', 'Enable/Disable Cocoapods') do |use_cocoapods| | ||
@options[:use_cocoapods] = use_cocoapods | ||
end | ||
|
||
opts.on('--[no-]git', 'Enable/Disable git') do |configure_git| | ||
@options[:configure_git] = configure_git | ||
end | ||
|
||
# Integer Options | ||
|
||
opts.on('-t', '--indentation_level N', 'Set indentation level') do |indentation_level| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we use dashes consistently here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. unfortunately we can't. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gross. I'll ask around. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could do There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alternatively, we could just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so how's this for all the flags:
It's not at all obvious that |
||
@options[:indentation_level] = indentation_level | ||
end | ||
|
||
# String Options | ||
|
||
opts.on('-n', '--project_name [PROJECT_NAME]', 'Set project name') do |name| | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto above. This should probably be |
||
@options[:project_name] = name | ||
end | ||
|
||
opts.on('-c', '--company [COMPANY]', 'Set project company') do |company| | ||
@options[:company] = company | ||
end | ||
|
||
opts.on('-a', '--author [AUTHOR]', 'Set project author') do |author| | ||
@options[:author] = author | ||
end | ||
|
||
opts.on('-p', '--prefix [PREFIX]', 'Set project prefix') do |prefix| | ||
@options[:prefix] = prefix | ||
end | ||
|
||
opts.on('-i', '--identifier [IDENTIFIER]', 'Set project company ID (com.example)') do |identifier| | ||
@options[:company_identifier] = identifier | ||
end | ||
end | ||
end | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,10 @@ | ||
module Liftoff | ||
class ConfigurationParser | ||
|
||
def initialize(cli_options) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we call this argument |
||
@cli_options = cli_options | ||
end | ||
|
||
def project_configuration | ||
@configuration ||= evaluated_configuration | ||
end | ||
|
@@ -10,7 +14,8 @@ def project_configuration | |
def evaluated_configuration | ||
default_configuration. | ||
merge(user_configuration). | ||
merge(local_configuration) | ||
merge(local_configuration). | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Place the . on the next line, together with the method name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a new addition to our style guide, but it would probably be good to go ahead and make this change now since we're messing around in here. |
||
merge(@cli_options) | ||
end | ||
|
||
def default_configuration | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need these comments.