Class: Sombrero::CLI
- Inherits:
-
Object
- Object
- Sombrero::CLI
- Includes:
- Assertions, Helpers
- Defined in:
- lib/sombrero/cli.rb,
lib/sombrero/cli/app.rb,
lib/sombrero/cli/docker.rb,
lib/sombrero/cli/helpers.rb,
lib/sombrero/cli/generator.rb,
lib/sombrero/cli/app/update.rb,
lib/sombrero/cli/assertions.rb,
lib/sombrero/cli/app/install.rb,
lib/sombrero/cli/docker/build.rb,
lib/sombrero/cli/docker/update.rb,
lib/sombrero/cli/docker/install.rb
Defined Under Namespace
Modules: Assertions, Docker, Helpers Classes: App, Generator
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ CLI
constructor
A new instance of CLI.
- #unknown_instruction_error!(instruction, *available_instructions) ⇒ Object
- #usage ⇒ Object
Methods included from Assertions
#assert_config_file_exists, #assert_directory_does_not_exists, #assert_directory_exists, #assert_directory_provided, #assert_empty_directory, #assert_installable_dir, #assert_is_app_dir, #assert_is_docker_dir, #assert_valid_api_name_given
Methods included from Helpers
#create_dirname_for, #display_error, #expanded_path, #extract_namespace, #fatal_error!, #make_executable, #working_dir_opted?
Constructor Details
#initialize(args) ⇒ CLI
Returns a new instance of CLI.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sombrero/cli.rb', line 15 def initialize args case command = args[0] when 'a', 'app' app(args) when 'g', 'gen', 'generate' generator(args) when 'd', 'docker' docker(args) when nil, '-h', '--help' usage else display_error "Unknown command #{command}" usage end end |
Class Method Details
.run(cmd) ⇒ Object
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/sombrero/cli.rb', line 174 def self.run cmd puts "", "$ #{cmd}" PTY.spawn cmd do |r, w, pid| begin r.sync r.each_char do |char| print(char) end rescue Errno::EIO => e # simply ignoring this ensure Process.wait(pid) end end end |
Instance Method Details
#unknown_instruction_error!(instruction, *available_instructions) ⇒ Object
169 170 171 |
# File 'lib/sombrero/cli.rb', line 169 def unknown_instruction_error! instruction, *available_instructions fatal_error! "Unknown instruction #{instruction}. Use one of #{available_instructions*', '}" end |
#usage ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/sombrero/cli.rb', line 32 def usage puts " === Install a new app === $ sombrero [app || a] [install || i] [dir || .] === Update existing app === $ sombrero [app || a] [update || u] [dir || .] === Generate a new API === $ sombrero [generate || g] [api || a] [api name] [dir || .] === Install Docker recipes === $ sombrero [docker || d] [install || i] [dir || .] === Update Docker recipes === $ sombrero [docker || d] [update || u] [dir || .] === Build Docker image and install run script === $ sombrero [docker || d] [build || b] [dir || .] [-u] [-p] If -u option provided it will only update the run script without building the image. If -p option provided it will try to push the image to Docker registry after successful build. === Usage === $ sombrero [-h || --help] ".split("\n").map {|l| "\t" + l.strip}.join("\n") end |