Class: Strap::CLI
- Inherits:
-
Thor
- Object
- Thor
- Strap::CLI
- Defined in:
- lib/strap/cli.rb
Instance Method Summary collapse
Instance Method Details
#go(strapfile = "Strapfile") ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/strap/cli.rb', line 34 def go(strapfile = "Strapfile") unless File.exists?(strapfile) say "No Strapfile in current directory. Use the 'strap init PATH' command first to setup your project directory and to initialize a Strapfile.", :red return false end config = Strap::Config.new(strapfile) core = Strap::Core.new(self) core.clone_repo(config.source_repo) core.create_database(config.db_user, config.db_password, config.db_socket, config.db_name, config.db_port, config.db_host) core.import_to_database(config.sql, config.db_user, config.db_password, config.db_socket, config.db_name, config.db_port, config.db_host) config. config.run_replace config.run_rename_files core.commit_to_repo(config.destination_repo) config.run_after_bootstrap say "Strap project bootstrapped!. Happy coding :)" end |
#init(path) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/strap/cli.rb', line 20 def init(path) if File.exists?(path) say "That directory already exists", :red else template = [:template] core = Strap::Core.new(self) core.create_project_directory(path) core.create_config(path, template) core.update_database_name(path) say "Strap project created. Now edit the Strapfile and run 'strap go' from the project directory to bootstrap your project." end end |
#install ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/strap/cli.rb', line 8 def install if File.exists?(File.('~/.strap')) say "'~/.strap' directory already exists", :red else Dir::mkdir(File.('~/.strap')) FileUtils.cp(CONFIG_TEMPLATE, File.('~/.strap/default')) say "'~/.strap' directory created. Add some template files.", :cyan end end |