diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2017-11-15 21:31:50 +0100 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2017-11-15 21:31:57 +0100 |
commit | 68479d09ba6bbd583055672eb70518c1586ae534 (patch) | |
tree | 81f7864cc1340921037fdd6c35642e105aaa04ea /railties/lib/rails/command/helpers | |
parent | 415d0543a527dcd2e099dcd819c6938f3dcac54a (diff) | |
parent | 7a8728a03986489e1c843ed850afc2c16fb6eb06 (diff) | |
download | rails-68479d09ba6bbd583055672eb70518c1586ae534.tar.gz rails-68479d09ba6bbd583055672eb70518c1586ae534.tar.bz2 rails-68479d09ba6bbd583055672eb70518c1586ae534.zip |
Merge branch 'freeletics-manage-multiple-credential-files'
Fixes https://github.com/rails/rails/pull/30940
Diffstat (limited to 'railties/lib/rails/command/helpers')
-rw-r--r-- | railties/lib/rails/command/helpers/editor.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/railties/lib/rails/command/helpers/editor.rb b/railties/lib/rails/command/helpers/editor.rb new file mode 100644 index 0000000000..5e9ecc05e7 --- /dev/null +++ b/railties/lib/rails/command/helpers/editor.rb @@ -0,0 +1,33 @@ +require "active_support/encrypted_file" + +module Rails + module Command + module Helpers + module Editor + private + def ensure_editor_available(command:) + if ENV["EDITOR"].to_s.empty? + say "No $EDITOR to open file in. Assign one like this:" + say "" + say %(EDITOR="mate --wait" #{command}) + say "" + say "For editors that fork and exit immediately, it's important to pass a wait flag," + say "otherwise the credentials will be saved immediately with no chance to edit." + + false + else + true + end + end + + def catch_editing_exceptions + yield + rescue Interrupt + say "Aborted changing file: nothing saved." + rescue ActiveSupport::EncryptedFile::MissingKeyError => error + say error.message + end + end + end + end +end |