lib/chronicle/etl/cli/jobs.rb in chronicle-etl-0.5.2 vs lib/chronicle/etl/cli/jobs.rb in chronicle-etl-0.5.3
- old
+ new
@@ -41,10 +41,19 @@
If you do not want to use the command line flags, you can also configure a job with a .yml config file. You can either specify the path to this file or use the filename and place the file in ~/.config/chronicle/etl/jobs/NAME.yml and call it with `--job NAME`
LONG_DESC
# Run an ETL job
def start(name = nil)
+ # If someone runs `$ chronicle-etl` with no arguments, show help menu.
+ # TODO: decide if we should check that there's nothing in stdin pipe
+ # in case user wants to actually run this sort of job stdin->null->stdout
+ if name.nil? && options[:extractor].nil?
+ m = Chronicle::ETL::CLI::Main.new
+ m.help
+ cli_exit
+ end
+
job_definition = build_job_definition(name, options)
if job_definition.plugins_missing?
missing_plugins = job_definition.errors[:plugins]
.select { |error| error.is_a?(Chronicle::ETL::PluginNotInstalledError) }
@@ -80,15 +89,14 @@
end
end
if write_config
Chronicle::ETL::Config.write("jobs", name, job_definition.definition)
- cli_exit(message: "Job saved. Run it with `$chronicle-etl jobs:run #{name}`")
+ cli_exit(message: "Job saved. Run it with `$ chronicle-etl jobs:run #{name}`")
else
cli_fail(message: "\nJob not saved")
end
-
rescue Chronicle::ETL::JobDefinitionError => e
cli_fail(message: "Job definition error", exception: e)
end
desc "show", "Show details about a job"
@@ -134,9 +142,11 @@
job_definition.apply_default_secrets
job = Chronicle::ETL::Job.new(job_definition)
runner = Chronicle::ETL::Runner.new(job)
runner.run!
+ rescue RunnerError => e
+ cli_fail(message: "#{e.message}", exception: e)
end
# TODO: probably could merge this with something in cli/plugin
def install_missing_plugins(missing_plugins)
prompt = TTY::Prompt.new