Skip to content

Commit f0eedb7

Browse files
committed
feat: appmap-agent-setup as a separate command not using GLI library
1 parent 0d0b43c commit f0eedb7

File tree

4 files changed

+23
-52
lines changed

4 files changed

+23
-52
lines changed

appmap.gemspec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Gem::Specification.new do |spec|
3333
spec.require_paths = ['lib']
3434

3535
spec.add_dependency 'activesupport'
36-
spec.add_dependency 'gli'
3736
spec.add_dependency 'method_source'
3837
spec.add_dependency 'rack'
3938
spec.add_dependency 'reverse_markdown'

exe/appmap-agent-init

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env ruby
2+
# frozen_string_literal: true
3+
4+
require 'optparse'
5+
require 'appmap'
6+
require 'appmap/command/agent_setup/init'
7+
8+
@options = {:config_file => AppMap::DEFAULT_CONFIG_FILE_PATH}
9+
10+
OptionParser.new do |parser|
11+
parser.banner = 'Usage: bundle exec exe/appmap-agent-init [options]'
12+
13+
description = "AppMap configuration file path (default: #{AppMap::DEFAULT_CONFIG_FILE_PATH})"
14+
parser.on('-c', '--config=FILEPATH', description) do |filepath|
15+
@options[:config_file] = filepath
16+
end
17+
end.parse!
18+
19+
AppMap::Command::AgentSetup::Init.new(@options[:config_file]).perform

exe/appmap-agent-setup

Lines changed: 0 additions & 47 deletions
This file was deleted.

test/agent_setup_cli_test.rb renamed to test/agent_setup_init_test.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
require 'test_helper'
55

6-
class AgentSetupCLITest < Minitest::Test
6+
class AgentSetupInitTest < Minitest::Test
77
CONFIG_FILENAME = '123.yml'
88
SUBFOLDER_CONFIG_FILEPATH = 'conf/123.yml'
99
EXPECTED_CONFIG_CONTENT = %(name: appmap-ruby
@@ -12,13 +12,13 @@ class AgentSetupCLITest < Minitest::Test
1212
)
1313

1414
def test_init_when_config_exists
15-
output = `./exe/appmap-agent-setup init`
15+
output = `./exe/appmap-agent-init`
1616
assert_equal 0, $CHILD_STATUS.exitstatus
1717
assert_includes output, 'The AppMap config file appmap.yml already exists.'
1818
end
1919

2020
def test_init_with_custom_config_filename
21-
output = `./exe/appmap-agent-setup -c #{CONFIG_FILENAME} init`
21+
output = `./exe/appmap-agent-init -c #{CONFIG_FILENAME}`
2222
assert_equal 0, $CHILD_STATUS.exitstatus
2323
assert_includes output, "The following AppMap config file #{CONFIG_FILENAME} has been created:"
2424
assert_equal EXPECTED_CONFIG_CONTENT, File.read(CONFIG_FILENAME)
@@ -27,7 +27,7 @@ def test_init_with_custom_config_filename
2727
end
2828

2929
def test_init_with_custom_config_file_in_subfolder
30-
output = `./exe/appmap-agent-setup -c #{SUBFOLDER_CONFIG_FILEPATH} init`
30+
output = `./exe/appmap-agent-init --config=#{SUBFOLDER_CONFIG_FILEPATH}`
3131
assert_equal 0, $CHILD_STATUS.exitstatus
3232
assert_includes output, "The following AppMap config file #{SUBFOLDER_CONFIG_FILEPATH} has been created:"
3333
assert_equal EXPECTED_CONFIG_CONTENT, File.read(SUBFOLDER_CONFIG_FILEPATH)

0 commit comments

Comments
 (0)