Class: Harnex::Status
- Inherits:
-
Object
- Object
- Harnex::Status
- Defined in:
- lib/harnex/commands/status.rb
Constant Summary collapse
- DESCRIPTION_WIDTH =
30- REPO_WIDTH =
20
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv) ⇒ Status
constructor
A new instance of Status.
- #run ⇒ Object
Constructor Details
#initialize(argv) ⇒ Status
Returns a new instance of Status.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/harnex/commands/status.rb', line 25 def initialize(argv) @argv = argv.dup @options = { id: nil, repo_path: Dir.pwd, all: false, json: false, help: false } end |
Class Method Details
.usage(program_name = "harnex status") ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/harnex/commands/status.rb', line 12 def self.usage(program_name = "harnex status") <<~TEXT Usage: #{program_name} [options] Options: --id ID Show a specific session --repo PATH Filter to PATH's repo root (default: current repo) --all List sessions across all repos --json Output JSON instead of a table -h, --help Show this help TEXT end |
Instance Method Details
#run ⇒ Object
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 |
# File 'lib/harnex/commands/status.rb', line 36 def run parser.parse!(@argv) if @options[:help] puts self.class.usage return 0 end sessions = load_sessions if @options[:json] puts JSON.generate(sessions) return 0 end if sessions.empty? if @options[:all] puts "No active harnex sessions." else puts "No active harnex sessions for #{Harnex.resolve_repo_root(@options[:repo_path])}." end return 0 end puts render_table(sessions) 0 end |