8000 Allow the user to specify a path from the CLI (#77) by champo · Pull Request #209 · liftoffcli/liftoff · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow the user to specify a path from the CLI (#77) #209

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/liftoff/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@ def run

def parse_command_line_options
global_options.parse!(@argv)
@options[:path] = @argv.first
end

def global_options
OptionParser.new do |opts|
opts.banner = 'usage: liftoff [-v | --version] [-h | --help] [config options]'
opts.banner = 'usage: liftoff [-v | --version] [-h | --help] [config options] [path]'

opts.on('-v', '--version', 'Display the version and exit') do
puts "Version: #{Liftoff::VERSION}"
Expand Down
2 changes: 1 addition & 1 deletion lib/liftoff/launchpad.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def liftoff(options)
validate_template
fetch_options

file_manager.create_project_dir(@config.project_name) do
file_manager.create_project_dir(@config.path) do
generate_project
setup_cocoapods
generate_templates
Expand Down
6 changes: 5 additions & 1 deletion lib/liftoff/project_configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ class ProjectConfiguration

attr_writer :author,
:company_identifier,
:use_tabs
:use_tabs,
:path

def initialize(liftoffrc)
deprecations = DeprecationManager.new
Expand Down Expand Up @@ -74,6 +75,9 @@ def test_target_groups
@test_target_templates[@project_template]
end

def path
@path || project_name
end
private

def normalized_company_name
Expand Down
24 changes: 24 additions & 0 deletions spec/project_configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,30 @@
end
end

describe '#path' do
context 'when the path is not given in the constructor' do
it 'returns the project name' do
config = Liftoff::ProjectConfiguration.new({
:project_name => 'My Cool Project'
})

expect(config.path).to eq 'My Cool Project'
end

end

context 'when the path is given in the constructor' do
it 'returns the given path' do
config = Liftoff::ProjectConfiguration.new({
:path => 'Another Path'
})

expect(config.path).to eq 'Another Path'
end
end

end

def build_config(name)
app_templates = build_templates('app')
test_templates = build_templates('test')
Expand Down
0