Class: Sxn::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/sxn/CLI.rb

Overview

Main CLI class using Thor framework

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = ARGV, local_options = {}, config = {}) ⇒ CLI

Returns a new instance of CLI.



15
16
17
18
19
# File 'lib/sxn/CLI.rb', line 15

def initialize(args = ARGV, local_options = {}, config = {})
  super
  @ui = Sxn::UI::Output.new
  setup_environment
end

Class Method Details

.exit_on_failure?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/sxn/CLI.rb', line 11

def self.exit_on_failure?
  true
end

Instance Method Details

#activate(session_name = nil) ⇒ Object



91
92
93
94
95
# File 'lib/sxn/CLI.rb', line 91

def activate(session_name = nil)
  Commands::Sessions.new.activate(session_name)
rescue Sxn::Error => e
  handle_error(e)
end

#add(session_name) ⇒ Object



44
45
46
47
48
# File 'lib/sxn/CLI.rb', line 44

def add(session_name)
  Commands::Sessions.new.add(session_name)
rescue Sxn::Error => e
  handle_error(e)
end

#archive(session_name = nil) ⇒ Object



84
85
86
87
88
# File 'lib/sxn/CLI.rb', line 84

def archive(session_name = nil)
  Commands::Sessions.new.archive(session_name)
rescue Sxn::Error => e
  handle_error(e)
end

#configObject



134
135
136
137
138
# File 'lib/sxn/CLI.rb', line 134

def config
  show_config
rescue Sxn::Error => e
  handle_error(e)
end

#currentObject



67
68
69
70
71
# File 'lib/sxn/CLI.rb', line 67

def current
  Commands::Sessions.new.current
rescue Sxn::Error => e
  handle_error(e)
end

#init(folder = nil) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/sxn/CLI.rb', line 31

def init(folder = nil)
  # steep:ignore:start - Thor dynamic argument validation handled at runtime
  # Thor framework uses metaprogramming for argument parsing that can't be statically typed.
  # Runtime validation ensures type safety through Thor's built-in validation.
  Commands::Init.new.init(folder)
  # steep:ignore:end
rescue Sxn::Error => e
  handle_error(e)
end

#listObject



59
60
61
62
63
# File 'lib/sxn/CLI.rb', line 59

def list
  Commands::Sessions.new.list
rescue Sxn::Error => e
  handle_error(e)
end

#projects(subcommand = nil, *args) ⇒ Object



98
99
100
101
102
# File 'lib/sxn/CLI.rb', line 98

def projects(subcommand = nil, *args)
  Commands::Projects.start([subcommand, *args].compact)
rescue Sxn::Error => e
  handle_error(e)
end

#remove(session_name = nil) ⇒ Object



75
76
77
78
79
80
81
# File 'lib/sxn/CLI.rb', line 75

def remove(session_name = nil)
  cmd = Commands::Sessions.new
  cmd.options = options
  cmd.remove(session_name)
rescue Sxn::Error => e
  handle_error(e)
end

#rules(subcommand = nil, *args) ⇒ Object



119
120
121
122
123
# File 'lib/sxn/CLI.rb', line 119

def rules(subcommand = nil, *args)
  Commands::Rules.start([subcommand, *args].compact)
rescue Sxn::Error => e
  handle_error(e)
end

#sessions(subcommand = nil, *args) ⇒ Object



105
106
107
108
109
# File 'lib/sxn/CLI.rb', line 105

def sessions(subcommand = nil, *args)
  Commands::Sessions.start([subcommand, *args].compact)
rescue Sxn::Error => e
  handle_error(e)
end

#statusObject



126
127
128
129
130
# File 'lib/sxn/CLI.rb', line 126

def status
  show_status
rescue Sxn::Error => e
  handle_error(e)
end

#use(session_name) ⇒ Object



51
52
53
54
55
# File 'lib/sxn/CLI.rb', line 51

def use(session_name)
  Commands::Sessions.new.use(session_name)
rescue Sxn::Error => e
  handle_error(e)
end

#versionObject



22
23
24
25
# File 'lib/sxn/CLI.rb', line 22

def version
  puts "sxn #{Sxn::VERSION}"
  puts "Session management for multi-repository development"
end

#worktree(subcommand = nil, *args) ⇒ Object



112
113
114
115
116
# File 'lib/sxn/CLI.rb', line 112

def worktree(subcommand = nil, *args)
  Commands::Worktrees.start([subcommand, *args].compact)
rescue Sxn::Error => e
  handle_error(e)
end