Class: FaaStRuby::Command::Project::New
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from BaseCommand
#has_user_logged_in?, #help, #load_credentials, #load_yaml, #say, spin, #spin, #write_file
Constructor Details
#initialize(args) ⇒ New
Returns a new instance of New.
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/faastruby/cli/commands/project/new.rb', line 20
def initialize(args)
@args = args
help
@missing_args = []
FaaStRuby::CLI.error(@missing_args, color: nil) if missing_args.any?
@project_name = @args.shift
FaaStRuby::CLI.error("The project name must have between 3 and 15 characters, and can only have letters, numbers and dashes.") unless name_valid?
@base_dir = "./#{@project_name}"
parse_options
@options['project_type'] ||= 'web'
end
|
Class Method Details
.help ⇒ Object
45
46
47
|
# File 'lib/faastruby/cli/commands/project/new.rb', line 45
def self.help
"new-project PROJECT_NAME [ARGS]"
end
|
Instance Method Details
#run ⇒ Object
32
33
34
35
36
37
38
39
40
41
42
43
|
# File 'lib/faastruby/cli/commands/project/new.rb', line 32
def run
dir_exists?
create_dir
create_config
install_functions
git_init
puts "Project '#{@project_name}' initialized."
puts "Now run:"
puts "$ cd #{@project_name}"
puts "$ faastruby local\n\n"
puts "Then visit http://localhost:3000"
end
|
#usage ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/faastruby/cli/commands/project/new.rb', line 49
def usage
puts "Usage: faastruby #{self.class.help}"
puts %(
--api # Initialize a project folder using an API template
--web # (Default) Initialize a project folder using a WEB template
)
end
|