Class: Appril::CLI
- Inherits:
-
Object
- Object
- Appril::CLI
- Includes:
- App, Assertions, Docker, Generator, Helpers
- Defined in:
- lib/appril-cli.rb,
lib/appril-cli.rb,
lib/appril-cli/app.rb,
lib/appril-cli/docker.rb,
lib/appril-cli/helpers.rb,
lib/appril-cli/version.rb,
lib/appril-cli/generator.rb,
lib/appril-cli/app/update.rb,
lib/appril-cli/assertions.rb,
lib/appril-cli/app/install.rb,
lib/appril-cli/docker/build.rb,
lib/appril-cli/docker/update.rb,
lib/appril-cli/generator/api.rb,
lib/appril-cli/docker/install.rb
Defined Under Namespace
Modules: App, Assertions, Docker, Generator, Helpers
Constant Summary collapse
- BASE_DIR =
Pathname.new(File.('../..', __FILE__))
- BOILERPLATE_DIR =
BASE_DIR / 'boilerplate'
- VERSION =
'0.0.9'.freeze
Constants included from App
Constants included from Docker
Docker::BUILD_FILE, Docker::CLEANUP_FILE, Docker::CONFIG_FILE, Docker::DOCKER_DIR, Docker::PREPARE_BUILD_FILE, Docker::START_FILE
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 Generator
Methods included from App
#app, #app_install, #app_update
Methods included from Docker
#docker, #docker_build, #docker_install, #docker_update
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.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/appril-cli.rb', line 29 def initialize args case command = args[0] when 'a', 'app' app(args) when 'g', 'gen', 'generate' generator(args) when 'd', 'docker' docker(args) when 'v', '-v', '--version' puts VERSION when nil, '-h', '--help' usage else display_error "Unknown command #{command}" usage end end |
Class Method Details
.run(cmd) ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
# File 'lib/appril-cli.rb', line 86 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
81 82 83 |
# File 'lib/appril-cli.rb', line 81 def unknown_instruction_error! instruction, *available_instructions fatal_error! "Unknown instruction #{instruction}. Use one of #{available_instructions*', '}" end |
#usage ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/appril-cli.rb', line 48 def usage puts " Arguments in round brackets are required. Arguments in square brackets are optional. === Install a new app === $ appril (app || a) (install || i) (dir || .) [-crudle] * If -crudle option provided it will install a Crudle app === Update existing app === $ appril (app || a) (update || u) (dir || .) === Generate a new API === $ appril (generate || g) (api) (api name) (dir || .) === Install Docker builder === $ appril (docker || d) (install || i) (dir || .) === Update Docker builder === $ appril (docker || d) (update || u) (dir || .) === Build Docker image and install run script === $ appril (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 === $ appril [-h || --help] ".split("\n").map {|l| "\t" + l.strip}.join("\n") end |