Module: RubyProgress::FillCLI
- Defined in:
- lib/ruby-progress/fill_cli.rb,
lib/ruby-progress/cli/fill_options.rb
Overview
CLI module for Fill command rubocop:disable Metrics/ClassLength
Defined Under Namespace
Modules: Options
Class Method Summary collapse
-
.run ⇒ void
Entrypoint for the ‘prg fill` CLI.
Class Method Details
.run ⇒ void
This method returns an undefined value.
Entrypoint for the ‘prg fill` CLI. Parses options and dispatches to the matching behavior (auto-advance, command-run, daemon, report).
19 20 21 22 23 24 25 26 27 28 29 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 |
# File 'lib/ruby-progress/fill_cli.rb', line 19 def run trap('INT') do Utils.show_cursor exit end = RubyProgress::FillCLI::Options. # Handle basic output flags first if [:help] puts RubyProgress::FillCLI::Options.help_text exit end if [:version] puts "Fill version #{RubyProgress::FILL_VERSION}" exit end if [:show_styles] show_fill_styles exit end # Handle daemon control first if [:status] || [:stop] pid_file = resolve_pid_file(, :status_name) if [:status] Daemon.show_status(pid_file) else Daemon.stop_daemon_by_pid_file(pid_file, message: [:stop_success], checkmark: [:stop_checkmark], error: ![:stop_error].nil?) end exit end # Parse style option parsed_style = parse_fill_style([:style]) if [:daemon] # Resolve pid file and honor daemon-as/name pid_file = resolve_pid_file(, :daemon_name) [:pid_file] = pid_file # Background without detaching so progress bar remains visible in current terminal PrgCLI.backgroundize run_daemon_mode(, parsed_style) elsif [:current] show_current_percentage(, parsed_style) elsif [:report] show_progress_report(, parsed_style) elsif [:advance] || [:complete] || [:cancel] handle_progress_commands(, parsed_style) else run_auto_advance_mode(, parsed_style) end end |