Skip to content

Commit

Permalink
[#186452718] Add new hints to 'Did you know'
Browse files Browse the repository at this point in the history
  • Loading branch information
steevokovsky-mkd committed Nov 17, 2023
1 parent 9e37a46 commit 0ed2cde
Show file tree
Hide file tree
Showing 22 changed files with 49 additions and 23 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ You may abbreviate commands by typing only their first letters, e.g. `geordi
con` will boot a development console, `geordi set -t` will setup a project and
run tests afterwards.

Commands will occasionally print "did you know" hints of other Geordi features.

You can always run `geordi help <command>` to quickly look up command help.

### `geordi branch`
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ You may abbreviate commands by typing only their first letters, e.g. `geordi
con` will boot a development console, `geordi set -t` will setup a project and
run tests afterwards.
Commands will occasionally print "did you know" hints of other Geordi features.
You can always run `geordi help <command>` to quickly look up command help.
TEXT

Expand Down
5 changes: 5 additions & 0 deletions lib/geordi/commands/capistrano.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,9 @@ def capistrano(*args)

Util.run!(command, fail_message: 'Capistrano failed. Have a look!')
end

Hint.did_you_know [
:deploy,
:rake,
]
end
4 changes: 4 additions & 0 deletions lib/geordi/commands/chromedriver_update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ def chromedriver_update
require 'geordi/chromedriver_updater'

ChromedriverUpdater.new.run(options)

Hint.did_you_know [
'Geordi can automatically keep chromedriver up-to-date. See `geordi help chromedriver-update`.',
] unless options.quiet_if_matching
end
2 changes: 1 addition & 1 deletion lib/geordi/commands/clean.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def clean
end

Hint.did_you_know [
:remove_executable_flags
:remove_executable_flags,
]
end
3 changes: 2 additions & 1 deletion lib/geordi/commands/commit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def commit(*git_args)
Gitpt.new.run_commit(git_args)

Hint.did_you_know [
:branch
:branch,
:deploy,
]
end
1 change: 1 addition & 0 deletions lib/geordi/commands/console.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def console(target = 'development', *_args)
Hint.did_you_know [
:shelll,
[:console, :select_server],
'You only need to type the unique prefix of a command to run it. `geordi con` will work as well.',
]

if target == 'development'
Expand Down
3 changes: 2 additions & 1 deletion lib/geordi/commands/cucumber.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ def cucumber(*args)
[:cucumber, :containing],
[:cucumber, :debug],
[:cucumber, :rerun],
'Geordi can automatically update chromedriver before Cucumber tests. See `geordi help chromedriver-update`.'
'Geordi can automatically keep chromedriver up-to-date. See `geordi help chromedriver-update`.',
'You only need to type the unique prefix of a command to run it. `geordi cuc` will work as well.',
]
else
Interaction.note 'Cucumber not employed.'
Expand Down
3 changes: 2 additions & 1 deletion lib/geordi/commands/delete_dumps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def delete_dumps(*locations)

Hint.did_you_know [
:clean,
:drop_databases
:drop_databases,
:dump,
]
end
2 changes: 1 addition & 1 deletion lib/geordi/commands/deploy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def deploy(target_stage = nil)

Hint.did_you_know [
:capistrano,
:security_update
:security_update,
]
else
Util.run!("git checkout #{source_branch}")
Expand Down
2 changes: 1 addition & 1 deletion lib/geordi/commands/drop_databases.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,6 @@ def drop_databases
cleaner.clean_postgres unless options.mysql_only

Hint.did_you_know [
:delete_dumps
:delete_dumps,
]
end
2 changes: 1 addition & 1 deletion lib/geordi/commands/dump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,6 @@ def dump(target = nil, *_args)
:delete_dumps,
:drop_databases,
:migrate,
'Geordi can load a dump directly into the local database if passed a Capistrano stage and the option -l. See `geordi help dump`.'
'Geordi can load a dump directly into the local database if passed a Capistrano stage and the option -l. See `geordi help dump`.',
]
end
2 changes: 1 addition & 1 deletion lib/geordi/commands/rake.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ def rake(*args)
end

Hint.did_you_know [
:capistrano
:capistrano,
]
end
2 changes: 1 addition & 1 deletion lib/geordi/commands/remove_executable_flags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ def remove_executable_flags
Interaction.success 'Done.'

Hint.did_you_know [
:clean
:clean,
]
end
9 changes: 6 additions & 3 deletions lib/geordi/commands/rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ def rspec(*files)
puts
Util.run!(command.join(' '), fail_message: 'Specs failed.')

Hint.did_you_know [
:cucumber
]
end

Hint.did_you_know [
:cucumber,
'Geordi can automatically keep chromedriver up-to-date. See `geordi help chromedriver-update`.',
'You only need to type the unique prefix of a command to run it. `geordi rs` will work as well.',
]
else
Interaction.note 'RSpec not employed.'
end
Expand Down
2 changes: 1 addition & 1 deletion lib/geordi/commands/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

def server(port = nil)
Hint.did_you_know [
[:server, :public]
[:server, :public],
]

invoke_geordi 'bundle_install'
Expand Down
5 changes: 4 additions & 1 deletion lib/geordi/commands/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ def setup
Interaction.success 'Successfully set up the project.'

Hint.did_you_know [
:update
:update,
:security_update,
[:setup, :dump],
[:setup, :test],
] unless options.dump || options.test

invoke_geordi 'dump', options.dump, load: true if options.dump
Expand Down
3 changes: 2 additions & 1 deletion lib/geordi/commands/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ def shelll(target, *_args)
require 'geordi/remote'

Hint.did_you_know [
:console
:console,
'You only need to type the unique prefix of a command to run it. `geordi sh` will work as well.',
]

Interaction.announce 'Opening a shell on ' + target
Expand Down
2 changes: 1 addition & 1 deletion lib/geordi/commands/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ def tests(*args)
end

Hint.did_you_know [
:deploy
:deploy,
]
end
4 changes: 3 additions & 1 deletion lib/geordi/commands/update.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ def update
Interaction.success 'Successfully updated the project.'

Hint.did_you_know [
:setup
:setup,
[:update, :dump],
[:update, :test],
] unless options.dump || options.test

invoke_geordi 'dump', options.dump, load: true if options.dump
Expand Down
2 changes: 1 addition & 1 deletion lib/geordi/hint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def did_you_know(hints)
if generated_hints.any? && should_print_hint
puts
puts generated_hints.sample
puts 'You can configure the probability for these hints by setting hint_probability to a unitless percent number in ~/.config/geordi/global.yml' unless settings_probability
puts "You can configure the probability for these hints by setting hint_probability to a unitless percent number in #{Settings::GLOBAL_SETTINGS_FILE_NAME}" unless settings_probability
end

generated_hints
Expand Down
10 changes: 5 additions & 5 deletions spec/did_you_know_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
array = [
:branch,
[:branch, :from_master],
'`geordi branch`'
'Custom message',
]

expect {subject.did_you_know(array)}.to output(/Did you know\? `geordi branch/).to_stdout
expect {subject.did_you_know(array)}.to output(/Did you know\? (`geordi branch( -m)?`|Custom message)/).to_stdout
expect(subject.did_you_know(array)).to eq([
'Did you know? `geordi branch` can check out a feature branch based on a story from Pivotal Tracker',
'Did you know? `geordi branch -m` can branch from master instead of the current branch',
'Did you know? `geordi branch`'
'Did you know? `geordi branch` can check out a feature branch based on a story from Pivotal Tracker.',
'Did you know? `geordi branch -m` can branch from master instead of the current branch.',
'Did you know? Custom message',
])
end
end
Expand Down

0 comments on commit 0ed2cde

Please sign in to comment.