Skip to content

Commit

Permalink
make it easier to startup
Browse files Browse the repository at this point in the history
  • Loading branch information
ninjapanzer committed Feb 12, 2023
1 parent ed61127 commit 253cc77
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 25 deletions.
26 changes: 19 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 12 additions & 12 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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
Expand Down
12 changes: 7 additions & 5 deletions cli.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
3 changes: 2 additions & 1 deletion config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
}
)
puts "Bundle install completed successfully"
exit 0
else
puts "Bundle install skipped"
end
Expand Down

0 comments on commit 253cc77

Please sign in to comment.