Skip to content

Commit 6feb5de

Browse files
committed
Standardize command loading and registration
1 parent ae988c8 commit 6feb5de

4 files changed

Lines changed: 34 additions & 16 deletions

File tree

Gemfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
PATH
22
remote: .
33
specs:
4-
linear-cli (0.3.9)
4+
linear-cli (0.3.10)
55
base64 (~> 0.2)
66
dry-cli (~> 1.0)
77
dry-cli-completion (~> 1.0)
88
gqli (~> 1.2)
99
httpx (~> 1.2)
1010
semantic_logger (~> 4.0)
11-
sequel
12-
sqlite3
13-
tty-markdown
11+
sequel (~> 5.0)
12+
sqlite3 (~> 1.7)
13+
tty-markdown (~> 0.7)
1414

1515
GEM
1616
remote: https://rubygems.org/

lib/linear/commands/issue.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,20 @@ module Rubyists
44
module Linear
55
# The Cli module is defined in cli.rb and is the top-level namespace for all CLI commands
66
module CLI
7-
# This ALIASES hash will return the key as the value if the key is not found,
8-
# otherwise it will return the value of the existing key
9-
ALIASES = Hash.new { |h, k| h[k] = k }.merge(
10-
'list' => 'ls'
11-
)
7+
module Issue
8+
# This ALIASES hash will return the key as the value if the key is not found,
9+
# otherwise it will return the value of the existing key
10+
ALIASES = Hash.new { |h, k| h[k] = k }.merge(
11+
'list' => 'ls'
12+
)
13+
end
1214

1315
Pathname.new(__FILE__).dirname.join('issue').glob('*.rb').each do |file|
1416
require file.expand_path
1517
register 'issue', aliases: %w[i] do |issue|
1618
basename = File.basename(file, '.rb')
1719
# The filename is expected to define a class of the same name, but capitalized
18-
issue.register ALIASES[basename], Issue.const_get(basename.capitalize)
20+
issue.register Issue::ALIASES[basename], Issue.const_get(basename.capitalize)
1921
end
2022
end
2123
end

lib/linear/commands/team.rb

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# frozen_string_literal: true
22

3-
Pathname.new(__FILE__).dirname.join('team').glob('*.rb').each do |file|
4-
require file.expand_path
3+
module Rubyists
4+
module Linear
5+
# The Cli module is defined in cli.rb and is the top-level namespace for all CLI commands
6+
module CLI
7+
module Team
8+
# This ALIASES hash will return the key as the value if the key is not found,
9+
# otherwise it will return the value of the existing key
10+
ALIASES = Hash.new { |h, k| h[k] = k }.merge(
11+
'list' => 'ls'
12+
)
13+
end
14+
15+
Pathname.new(__FILE__).dirname.join('team').glob('*.rb').each do |file|
16+
require file.expand_path
17+
register 'team', aliases: %w[t teams] do |team|
18+
basename = File.basename(file, '.rb')
19+
# The filename is expected to define a class of the same name, but capitalized
20+
team.register Team::ALIASES[basename], Team.const_get(basename.capitalize)
21+
end
22+
end
23+
end
24+
end
525
end

lib/linear/commands/team/list.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,6 @@ def teams_for(options)
3131
prepend Rubyists::Linear::CLI::Caller
3232
end
3333
end
34-
35-
register 'team', aliases: %w[t] do |team|
36-
team.register 'ls', Team::List
37-
end
3834
end
3935
end
4036
end

0 commit comments

Comments
 (0)