Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions lib/bolt/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,6 @@ def parse
# help text
options[:subcommand] = nil unless COMMANDS.include?(options[:subcommand])

if Bolt::Util.first_run?
FileUtils.touch(Bolt::Util.first_runs_free)

if options[:subcommand].nil? && $stdout.isatty
welcome_message
raise Bolt::CLIExit
end
end

# Update the parser for the subcommand (or lack thereof)
parser.update
puts parser.help
Expand Down Expand Up @@ -165,52 +156,6 @@ def parse
end
end

# TODO: Move this to the parser.
#
# Print a welcome message when users first install Bolt and run `bolt`,
# `bolt help` or `bolt --help`.
#
private def welcome_message
bolt = <<~BOLT
`.::-`
`.-:///////-.`
`-:////:. `-:///:- /ooo. .ooo/
`.-:///::///:-` `-//: ymmm- :mmmy .---.
:///:-. `.:////. -//: ymmm- :mmmy +mmm+
://. ///. -//: ymmm--/++/- `-/++/:` :mmmy-:smmms::-
://. ://. .://: ymmmdmmmmmmdo` .smmmmmmmmh: :mmmysmmmmmmmms
://. ://:///:-. ymmmh/--/hmmmy -mmmd/-.:hmmm+:mmmy.-smmms--.
://:.` .-////:-` ymmm- ymmm:hmmm- `dmmm/mmmy +mmm+
`-:///:-..:///:-.` ymmm- ommm/dmmm` hmmm+mmmy +mmm+
`.-:////:-` ymmm+ /mmmm.ommms` /mmmh:mmmy +mmmo
`-.` ymmmmmhhmmmmd: ommmmhydmmmy`:mmmy -mmmmdhd
oyyy+shddhs/` .+shddhy+- -yyyo .ohddhs


BOLT
example_cmd = if Bolt::Util.windows?
"Invoke-BoltCommand -Command 'hostname' -Targets localhost"
else
"bolt command run 'hostname' --target localhost"
end
prev_cmd = String.new("bolt")
prev_cmd << " #{@argv[0]}" unless @argv.empty?

message = <<~MSG
🎉 Welcome to OpenBolt #{VERSION}
😌 We're here to help bring order to the chaos
📖 Find our documentation at https://bolt.guide
🙋 Ask a question in #bolt on https://slack.puppet.com/
🔩 Contribute at https://github.com/puppetlabs/bolt/
💡 Not sure where to start? Try "#{example_cmd}"

We only print this message once. Run "#{prev_cmd}" again for help text.
MSG

$stdout.print "\033[36m#{bolt}\033[0m"
$stdout.print message
end

# TODO: Move this to the parser.
#
# Validate the command. Ensure that the subcommand and action are
Expand Down
20 changes: 0 additions & 20 deletions lib/bolt/util.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,6 @@ def read_optional_yaml_hash(path, file_name)
File.exist?(path) ? read_yaml_hash(path, file_name) : {}
end

def first_runs_free
# If this fails, use the system path instead
FileUtils.mkdir_p(Bolt::Config.user_path)
Bolt::Config.user_path + '.first_runs_free'
rescue StandardError
begin
# If using the system path fails, then don't bother with the welcome
# message
FileUtils.mkdir_p(Bolt::Config.system_path)
Bolt::Config.system_path + '.first_runs_free'
rescue StandardError
nil
end
end

def first_run?
!first_runs_free.nil? &&
!File.exist?(first_runs_free)
end

# If Puppet is loaded, we aleady have the path to the module and should
# just get it. This takes the path to a file provided by the user and a
# Puppet Parser scope object and tries to find the file, either as an
Expand Down
17 changes: 0 additions & 17 deletions pwsh_module/pwsh_bolt.psm1.erb
Original file line number Diff line number Diff line change
Expand Up @@ -90,20 +90,3 @@ end

}
<% end %>

<% unless ENV['BOLT_DISABLE_PWSH_WARNING'] -%>
function Write-DeprecationWarning
{
$FirstRunFile = "$HOME/.puppetlabs/etc/bolt/.first_runs_free"

if (-not(Test-Path -Path $FirstRunFile)) {
New-Item -ItemType File -Path $FirstRunFile -Force -ErrorAction SilentlyContinue

$Warning = "The PuppetBolt PowerShell module will no longer ship with Bolt packages in a future release. ";
$Warning += "Install the PuppetBolt PowerShell module from PowerShell Gallery instead using 'Import-Module PuppetBolt'."
Write-Warning $Warning
}
}

Write-DeprecationWarning
<% end -%>
22 changes: 0 additions & 22 deletions spec/unit/util_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -186,28 +186,6 @@
end
end

describe '#first_runs_free' do
it 'returns path to first run file under user-level default config dir' do
expect(Bolt::Util.first_runs_free).to eq(Bolt::Config.user_path + '.first_runs_free')
end

it 'falls back to system_path if user_path fails to be created' do
expect(FileUtils).to receive(:mkdir_p)
.with(Bolt::Config.user_path).and_raise(Errno::ENOENT, "No such file or directory")
expect(FileUtils).to receive(:mkdir_p)
.with(Bolt::Config.system_path).and_return([Bolt::Config.system_path])
expect(Bolt::Util.first_runs_free).to eq(Bolt::Config.system_path + '.first_runs_free')
end

it 'returns nil if both system_path and user_path fail to be created' do
expect(FileUtils).to receive(:mkdir_p)
.with(Bolt::Config.user_path).and_raise(Errno::ENOENT, "No such file or directory")
expect(FileUtils).to receive(:mkdir_p)
.with(Bolt::Config.system_path).and_raise(Errno::ENOENT, "No such file or directory")
expect(Bolt::Util.first_runs_free).to eq(nil)
end
end

describe '#prompt_yes_no' do
let(:outputter) { double('outputter', print_prompt: nil) }

Expand Down
Loading