Class: Fig::Command
- Inherits:
-
Object
- Object
- Fig::Command
- Defined in:
- lib/fig/command.rb,
lib/fig/command/action.rb,
lib/fig/command/options.rb,
lib/fig/command/action/get.rb,
lib/fig/command/action/help.rb,
lib/fig/command/action/clean.rb,
lib/fig/command/option_error.rb,
lib/fig/command/action/update.rb,
lib/fig/command/action/options.rb,
lib/fig/command/action/publish.rb,
lib/fig/command/action/version.rb,
lib/fig/command/options/parser.rb,
lib/fig/command/package_loader.rb,
lib/fig/command/package_applier.rb,
lib/fig/command/action/help_long.rb,
lib/fig/command/action/list_local.rb,
lib/fig/command/action/list_remote.rb,
lib/fig/command/action/role/update.rb,
lib/fig/command/action/list_configs.rb,
lib/fig/command/action/role/publish.rb,
lib/fig/command/action/publish_local.rb,
lib/fig/command/action/version_plain.rb,
lib/fig/command/action/list_variables.rb,
lib/fig/command/action/source_package.rb,
lib/fig/command/action/run_command_line.rb,
lib/fig/command/action/list_dependencies.rb,
lib/fig/command/action/role/list_as_json.rb,
lib/fig/command/action/role/list_as_yaml.rb,
lib/fig/command/action/update_if_missing.rb,
lib/fig/command/action/list_variables/json.rb,
lib/fig/command/action/list_variables/tree.rb,
lib/fig/command/action/list_variables/yaml.rb,
lib/fig/command/action/role/has_sub_action.rb,
lib/fig/command/action/role/list_all_configs.rb,
lib/fig/command/action/role/list_as_graphviz.rb,
lib/fig/command/action/role/list_base_config.rb,
lib/fig/command/action/run_command_statement.rb,
lib/fig/command/action/list_dependencies/json.rb,
lib/fig/command/action/list_dependencies/tree.rb,
lib/fig/command/action/list_dependencies/yaml.rb,
lib/fig/command/action/list_variables/default.rb,
lib/fig/command/action/role/has_no_sub_action.rb,
lib/fig/command/action/list_variables/graphviz.rb,
lib/fig/command/action/list_dependencies/default.rb,
lib/fig/command/action/list_dependencies/graphviz.rb,
lib/fig/command/action/list_variables/all_configs.rb,
lib/fig/command/action/role/list_dependencies_flat.rb,
lib/fig/command/action/dump_package_definition_text.rb,
lib/fig/command/action/list_dependencies/all_configs.rb,
lib/fig/command/action/role/list_from_data_structure.rb,
lib/fig/command/action/role/list_variables_in_a_tree.rb,
lib/fig/command/action/dump_package_definition_parsed.rb,
lib/fig/command/action/list_variables/json_all_configs.rb,
lib/fig/command/action/list_variables/tree_all_configs.rb,
lib/fig/command/action/list_variables/yaml_all_configs.rb,
lib/fig/command/action/role/list_variables_as_graphviz.rb,
lib/fig/command/action/role/list_dependencies_in_a_tree.rb,
lib/fig/command/action/role/list_walking_dependency_tree.rb,
lib/fig/command/action/list_dependencies/json_all_configs.rb,
lib/fig/command/action/list_dependencies/tree_all_configs.rb,
lib/fig/command/action/list_dependencies/yaml_all_configs.rb,
lib/fig/command/action/role/list_dependencies_as_graphviz.rb,
lib/fig/command/action/list_variables/graphviz_all_configs.rb,
lib/fig/command/action/list_dependencies/graphviz_all_configs.rb,
lib/fig/command/action/role/list_variables_from_data_structure.rb,
lib/fig/command/action/dump_package_definition_for_command_line.rb,
lib/fig/command/action/role/list_dependencies_from_data_structure.rb
Overview
Main program
Defined Under Namespace
Modules: Action Classes: ExecutionContext, OptionError, Options, PackageApplier, PackageLoader
Instance Method Summary collapse
-
#add_post_set_up_action(action) ⇒ Object
Extension mechanism for customizing Fig.
- #add_publish_listener(listener) ⇒ Object
-
#initialize ⇒ Command
constructor
A new instance of Command.
- #run_fig(argv, options = nil) ⇒ Object
- #run_fig_with_exception_handling(argv, options = nil) ⇒ Object
Constructor Details
#initialize ⇒ Command
Returns a new instance of Command.
130 131 132 133 |
# File 'lib/fig/command.rb', line 130 def initialize() @post_set_up_actions = [] @publish_listeners = [] end |
Instance Method Details
#add_post_set_up_action(action) ⇒ Object
Extension mechanism for customizing Fig.
118 119 120 121 122 |
# File 'lib/fig/command.rb', line 118 def add_post_set_up_action(action) @post_set_up_actions << action return end |
#add_publish_listener(listener) ⇒ Object
124 125 126 127 128 |
# File 'lib/fig/command.rb', line 124 def add_publish_listener(listener) @publish_listeners << listener return end |
#run_fig(argv, options = nil) ⇒ Object
30 31 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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/fig/command.rb', line 30 def run_fig(argv, = nil) @suppress_further_error_messages = false begin @options = || Fig::Command::Options.new() @options.process_command_line(argv) rescue Fig::UserInputError => error $stderr.puts error.to_s # Logging isn't set up yet. return Fig::Command::Action::EXIT_FAILURE end if not @options.exit_code.nil? return @options.exit_code end Fig::Logging.initialize_pre_configuration( @options.log_to_stdout(), @options.log_level(), ) actions = @options.actions() if actions.empty? return handle_nothing_to_do end actions.each do |action| if action.execute_immediately_after_command_line_parse? # Note that the action doesn't get an execution context. return action.execute() end end @descriptor = @options.descriptor check_descriptor_requirement() if actions.any? {|action| not action.allow_both_descriptor_and_file? } ensure_descriptor_and_file_were_not_both_specified() end () configure() set_up_base_package() invoke_post_set_up_actions() context = ExecutionContext.new( @base_package, @synthetic_package_for_command_line, base_config(), @environment, @repository, @non_repository_packages, @working_directory_maintainer, @operating_system, @package_source_description, @package_load_path_description ) actions.each do |action| action.execution_context = context exit_code = action.execute if exit_code != Fig::Command::Action::EXIT_SUCCESS return exit_code end end return Fig::Command::Action::EXIT_SUCCESS end |
#run_fig_with_exception_handling(argv, options = nil) ⇒ Object
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/fig/command.rb', line 101 def run_fig_with_exception_handling(argv, = nil) begin return run_fig(argv, ) rescue Fig::URLAccessDisallowedError => error urls = error.urls.join(', ') $stderr.puts \ "Access to #{urls} in #{error.package}/#{error.version} not allowed." rescue Fig::UserInputError => error (error) end @suppress_further_error_messages = true return Fig::Command::Action::EXIT_FAILURE end |