Skip to content

Commit 16b69d0

Browse files
committed
Only show relevant files when pass in --full option
1 parent fa91926 commit 16b69d0

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

lib/gel/command/env.rb

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22

33
class Gel::Command::Env < Gel::Command
44
def run(command_line)
5-
MarkdownFormatter.format(metadata)
5+
option = { full: (command_line.shift == "--full") }
6+
data = metadata(option)
7+
MarkdownFormatter.format(data)
68
end
79

810
private
911

10-
def metadata
11-
{
12+
def metadata(option)
13+
metadata = {
1214
"Gel" => gel_envs,
1315
"User" => user_envs,
1416
"Ruby" => ruby_envs,
15-
"Relevant Files" => RELEVANT_FILES,
1617
}
18+
if option[:full]
19+
metadata.merge!("Relevant Files" => RELEVANT_FILES)
20+
end
21+
metadata
1722
end
1823

1924
module MarkdownFormatter

test/command/env_test.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,17 @@
33
require "test_helper"
44

55
class EnvTest < Minitest::Test
6-
def test_help
6+
def test_env
77
output = capture_stdout { Gel::Command::Env.run(["env"]) }
88

9+
assert output =~ %r{## Gel}
10+
assert output =~ %r{## User}
11+
assert output =~ %r{## Ruby}
12+
end
13+
14+
def test_env_with_full
15+
output = capture_stdout { Gel::Command::Env.run(["env", "--full"]) }
16+
917
assert output =~ %r{## Gel}
1018
assert output =~ %r{## User}
1119
assert output =~ %r{## Ruby}

0 commit comments

Comments
 (0)