Skip to content

Commit ff7f6b7

Browse files
committed
chore(*): code cleanup & output formatting
1 parent b8410f4 commit ff7f6b7

File tree

6 files changed

+14
-14
lines changed

6 files changed

+14
-14
lines changed

src/commands/build.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ module Geode::Commands
1414

1515
add_usage "build [-p|--pipe] [targets...]"
1616
add_argument "targets", description: "the targets to build", multiple: true
17-
add_option 'p', "pipe", description: "pipes the build output"
17+
add_option 'p', "pipe", description: "pipe the build output"
1818
end
1919

2020
def run(arguments : Cling::Arguments, options : Cling::Options) : Nil

src/commands/format.cr

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@ module Geode::Commands
22
protected def self.format_command(command : Cling::Command) : String
33
String.build do |str|
44
if header = command.header
5-
str << header << "\n\n"
5+
str << header << '\n'
66
else
77
str << "Command".colorize.magenta << "" << command.name << '\n'
88
end
9+
str << '\n'
910

1011
if description = command.description
1112
str << description
@@ -14,17 +15,16 @@ module Geode::Commands
1415

1516
unless command.usage.empty?
1617
str << "Usage".colorize.magenta << '\n'
17-
command.usage.each do |use|
18-
str << "» " << use << '\n'
19-
end
18+
command.usage.each { |use| str << "» " << use << '\n' }
2019
str << '\n'
2120
end
2221

2322
unless command.children.empty?
2423
str << "Commands".colorize.magenta << '\n'
2524
max_size = command.children.keys.map(&.size).max + 4
25+
2626
command.children.each do |name, cmd|
27-
str << "» #{name}"
27+
str << "» " << name
2828
if summary = cmd.summary
2929
str << " " * (max_size - name.size)
3030
str << summary
@@ -36,16 +36,21 @@ module Geode::Commands
3636

3737
unless command.arguments.empty?
3838
str << "Arguments".colorize.magenta << '\n'
39+
max_size = 4 + command.arguments.keys.max_of &.size
40+
3941
command.arguments.each do |name, argument|
40-
str << "» #{name}\t#{argument.description}"
42+
str << "» " << name
43+
str << " " * (max_size - name.size)
44+
str << argument.description
4145
str << " (required)" if argument.required?
4246
str << '\n'
4347
end
4448
str << '\n'
4549
end
4650

4751
str << "Options".colorize.magenta << '\n'
48-
max_size = command.options.map { |n, o| n.size + (o.short ? 2 : 0) + 2 }.max + 2
52+
max_size = 2 + command.options.max_of { |n, o| 2 + n.size + (o.short ? 2 : 0) }
53+
4954
command.options.each do |name, option|
5055
name_size = 2 + option.long.size + (option.short ? 2 : -2)
5156

src/commands/list.cr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ module Geode::Commands
88
transitive dependencies will also be listed even if they are not directly
99
required by your project.
1010
DESC
11-
12-
add_usage "list"
1311
end
1412

1513
def run(arguments : Cling::Arguments, options : Cling::Options) : Nil

src/commands/version.cr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ module Geode::Commands
44
@name = "version"
55
@summary = "gets the version information about Geode"
66
@description = "Gets the version information about Geode."
7-
8-
add_usage "geode version"
97
end
108

119
def run(arguments : Cling::Arguments, options : Cling::Options) : Nil

src/commands/watch.cr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module Geode::Commands
88
add_argument "target", description: "the name of the target"
99
add_option 'c', "check-start", description: "check for the target executable at the start"
1010
add_option 'i', "interval", description: "the wait interval in seconds", type: :single, default: 0.5
11-
add_option 'p', "pipe", description: "pipes the build output"
11+
add_option 'p', "pipe", description: "pipe the build output"
1212
add_option 's', "skip-start", description: "skip building at the start"
1313
end
1414

src/shard.cr

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ module Geode
1919

2020
class Shard
2121
include YAML::Serializable
22-
include YAML::Serializable::Unmapped
2322

2423
NAME_REGEX = /\A[a-z][a-z0-9_-]+\z/
2524

0 commit comments

Comments
 (0)