lib/aptible/cli/agent.rb in aptible-cli-0.7.4 vs lib/aptible/cli/agent.rb in aptible-cli-0.7.5
- old
+ new
@@ -42,13 +42,23 @@
# Forward return codes on failures.
def self.exit_on_failure?
true
end
+ def initialize(*)
+ nag_toolbelt unless toolbelt?
+ super
+ end
+
desc 'version', 'Print Aptible CLI version'
def version
- puts "aptible-cli v#{Aptible::CLI::VERSION}"
+ bits = [
+ 'aptible-cli',
+ "v#{Aptible::CLI::VERSION}"
+ ]
+ bits << 'toolbelt' if toolbelt?
+ puts bits.join ' '
end
desc 'login', 'Log in to Aptible'
option :email
option :password
@@ -101,9 +111,43 @@
private
def deprecated(msg)
say "DEPRECATION NOTICE: #{msg}"
say 'Please contact support@aptible.com with any questions.'
+ end
+
+ def nag_toolbelt
+ # If you're reading this, it's possible you decided to not use the
+ # toolbelt and are a looking for a way to disable this warning. Look no
+ # further: to do so, edit the file `.aptible/nag_toolbelt` and put a
+ # timestamp far into the future. For example, writing 1577836800 will
+ # disable the warning until 2020.
+ nag_file = File.join ENV['HOME'], '.aptible', 'nag_toolbelt'
+ nag_frequency = 12.hours
+
+ last_nag = begin
+ Integer(File.read(nag_file))
+ rescue Errno::ENOENT, ArgumentError
+ 0
+ end
+
+ now = Time.now.utc.to_i
+
+ if last_nag < now - nag_frequency
+ $stderr.puts yellow([
+ 'You have installed the Aptible CLI from source.',
+ 'This is not recommended: some functionality may not work!',
+ 'Review this support topic for more information:',
+ 'https://www.aptible.com/support/topics/cli/how-to-install-cli/'
+ ].join("\n"))
+
+ FileUtils.mkdir_p(File.dirname(nag_file))
+ File.open(nag_file, 'w', 0o600) { |f| f.write(now.to_s) }
+ end
+ end
+
+ def toolbelt?
+ ENV['APTIBLE_TOOLBELT']
end
end
end
end