diff --git a/Gemfile b/Gemfile index 5368283..c598cd5 100644 --- a/Gemfile +++ b/Gemfile @@ -5,14 +5,26 @@ require 'yaml' source "https://rubygems.org" config_dir = File.join(Dir.home, '.cli') -config_commands = YAML.load_file(File.join(config_dir, 'config.yml'))['commands'] -config_commands.map do |command_options| - case - when command_options['path'].nil? - gem command_options['name'] - else - gem command_options['name'], path: File.join(config_dir, 'commands', command_options['name']) +yml_location = File.join(config_dir, 'config.yml') +if File.exist?(yml_location) + config_commands = YAML.load_file(yml_location)['commands'] + config_commands.map do |command_options| + puts command_options.inspect + case + when command_options['path'] + path = File.join(config_dir, 'commands', command_options['name']) + puts path + gem command_options['name'], path: path + when command_options['path_relative'] + path = File.join(Dir.pwd, command_options['name']) + puts path + gem command_options['name'], path: path + else + gem command_options['name'] + end end +else + puts "config not found skipping" end # Specify your gem's dependencies in cli.gemspec diff --git a/Gemfile.lock b/Gemfile.lock index 416bd03..5e96e01 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -12,16 +12,16 @@ PATH cli_survey cli_toolkit (~> 0.1.0) rubyfmt - sqlite3 (~> 1.4.2) + sqlite3 (~> 1.6) thor (~> 1.2.1) zeitwerk (~> 2.6.6) PATH - remote: /home/paulscoder/.cli/commands/cli_survey + remote: /home/paulscoder/repos/personal_cli/ruby/cli/cli_demo/cli_survey specs: cli_survey (0.1.0) launchy (~> 2.5.2) - sqlite3 (~> 1.4.2) + sqlite3 (~> 1.6) thor (~> 1.2.1) zeitwerk (~> 2.6.6) @@ -36,27 +36,27 @@ GEM launchy (2.5.2) addressable (~> 2.8) parallel (1.22.1) - parser (3.2.0.0) + parser (3.2.1.0) ast (~> 2.4.1) public_suffix (5.0.1) rainbow (3.1.1) rake (13.0.6) - regexp_parser (2.6.1) + regexp_parser (2.7.0) rexml (3.2.5) rspec (3.12.0) rspec-core (~> 3.12.0) rspec-expectations (~> 3.12.0) rspec-mocks (~> 3.12.0) - rspec-core (3.12.0) + rspec-core (3.12.1) rspec-support (~> 3.12.0) rspec-expectations (3.12.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) - rspec-mocks (3.12.2) + rspec-mocks (3.12.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.12.0) rspec-support (3.12.0) - rubocop (1.43.0) + rubocop (1.45.1) json (~> 2.3) parallel (~> 1.10) parser (>= 3.2.0.0) @@ -66,8 +66,8 @@ GEM rubocop-ast (>= 1.24.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.24.1) - parser (>= 3.1.1.0) + rubocop-ast (1.26.0) + parser (>= 3.2.1.0) ruby-progressbar (1.11.0) ruby2ruby (2.5.0) ruby_parser (~> 3.1) @@ -77,10 +77,10 @@ GEM rubyfmt (0.0.1) ruby2ruby (~> 2.0) sexp_processor (4.16.1) - sqlite3 (1.4.4) + sqlite3 (1.6.0-x86_64-linux) thor (1.2.1) unicode-display_width (2.4.2) - zeitwerk (2.6.6) + zeitwerk (2.6.7) PLATFORMS x86_64-linux diff --git a/cli.gemspec b/cli.gemspec index d2f3058..fa95655 100644 --- a/cli.gemspec +++ b/cli.gemspec @@ -35,17 +35,19 @@ Gem::Specification.new do |spec| spec.add_dependency "zeitwerk", "~> 2.6.6" spec.add_dependency "thor", "~> 1.2.1" - spec.add_dependency "sqlite3", "~> 1.4.2" + spec.add_dependency "sqlite3", "~> 1.6" spec.add_dependency "cli_toolkit", "~> 0.1.0" # load yaml config from the home directory .cli/config.yml and extract an array of commands config_dir = File.join(Dir.home, '.cli') - config_commands = YAML.load_file(File.join(config_dir, 'config.yml'))['commands'] - config_commands.map do |command_options| - spec.add_runtime_dependency command_options['name'] + config_file = File.join(config_dir, 'config.yml') + if File.exist?(config_file) + config_commands = YAML.load_file(config_file)['commands'] + config_commands.map do |command_options| + spec.add_runtime_dependency command_options['name'] + end end - # Uncomment to register a new dependency of your gem # spec.add_dependency "example-gem", "~> 1.0" diff --git a/config/config.yml b/config/config.yml index e62df6d..b6d5dfd 100644 --- a/config/config.yml +++ b/config/config.yml @@ -2,7 +2,8 @@ surveyDb: survey_db.sqlite surveySchema: db/survey_schema.sql commands: - name: cli_survey - path: commands/cli_survey + # path: commands/cli_survey + path_relative: ../cli_survey - name: bundler configs: - name: cli_survey diff --git a/lib/cli.rb b/lib/cli.rb index b7bb628..a1b6171 100644 --- a/lib/cli.rb +++ b/lib/cli.rb @@ -22,6 +22,7 @@ } ) puts "Bundle install completed successfully" + exit 0 else puts "Bundle install skipped" end