Class: MobileSecrets::Cli
- Inherits:
-
Object
- Object
- MobileSecrets::Cli
- Defined in:
- lib/mobile-secrets.rb
Instance Method Summary collapse
- #header ⇒ Object
- #options ⇒ Object
- #perform_action(command, argv_1, argv_2) ⇒ Object
- #print_options ⇒ Object
- #usage ⇒ Object
Instance Method Details
#header ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/mobile-secrets.rb', line 8 def header "Mobile Secrets HELP: ############################################################################################################################## ## %# #%%%( ##% ,%%% (%%/ *%%%% ,%%%/ .%%( (%%, #%%%#.(%%# #%%*.#%%% ,%%%%%.%%%%. #%%%%.#%%%.*%% %%%%*#%% ## ## % #%%%( % *%%%# /%%%( *%%%% %%%%, %%%* %, (%%%# #( .%%%( %% (%%%# %%%% %%%%. .%.*% %%%%* #% ## ## #%%%( %%%%# /%%%% *%%%% %%%%. .%%%%%%#. (%%%( ,% %%%%( ,# (%%%# .%%%% .%%%%. (* ,( %%%%* .# ## ## #%%%( %%%%# /%%%% /%%%% *%%%* *%%%%%%%% (%%%((%% %%%%( (%%%#.#%#, .%%%%.%%* %%%%, ## ## #%%%( #%%%# /%%%% /%%%% .( (%%%%%# (%%%( ,% %%%%( (%%%# *%%%# .%%%%. #* %%%%, ## ## %%%%( %%%# /%%%. /%%%% ,%, %%%/ (%%%( (# (%%%( *# #%%%# .%%%% .%%%% #, %%%%, ## ## %%%%%%( /%%**%%( ,%%%%%( ,%%#. /%%* #%%%(./%%# *%%# .## #%%%# .%%%%#/ .%%%% ,%%, %%%%, ## ##############################################################################################################################" end |
#options ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/mobile-secrets.rb', line 21 def opt = "" opt << "--init-gpg PATH \t\t\tInitialize GPG in the directory.\n" opt << "--create-template \t\t\tCreates a template yml file to configure the MobileSecrets\n" opt << "--import SECRETS_PATH \t\t\tAdds MobileSecrets to GPG secrets\n" opt << "--export PATH opt: ENCRYPTED_FILE_PATH \tCreates source file with obfuscated secrets at given PATH\n" opt << "--encrypt-file FILE PASSWORD \t\tEncrypt a single file with AES\n" opt << "--empty PATH \t\t\t\tGenerates a Secrets file without any data in it\n" opt << "--usage \t\t\t\tManual for using MobileSecrets.\n\n" opt << "Examples:\n" opt << "--import \"./MobileSecrets.yml\"\n" opt << "--export \"./Project/Src\\n" opt << "--init-gpg \".\"" opt end |
#perform_action(command, argv_1, argv_2) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/mobile-secrets.rb', line 47 def perform_action command, argv_1, argv_2 case command when "--create-template" FileUtils.cp("#{__dir__}/../lib/resources/example.yml", "#{Dir.pwd}#{File::SEPARATOR}MobileSecrets.yml") when "--export" return if argv_1 == nil encrypted_file_path = argv_2 ||= "secrets.gpg" secrets_handler = MobileSecrets::SecretsHandler.new secrets_handler.export_secrets argv_1, argv_2 when "--init-gpg" return if argv_1 == nil Dotgpg::Cli.new.init(argv_1) when "--import" return if argv_1 == nil gpg_file = argv_2 ||= "secrets.gpg" file = IO.read argv_1 MobileSecrets::SecretsHandler.new.encrypt gpg_file, file, nil when "--encrypt-file" file = argv_1 password = argv_2 MobileSecrets::SecretsHandler.new.encrypt_file password, file, "#{file}.enc" when "--empty" return if argv_1 == nil file_path = argv_1 MobileSecrets::SourceRenderer.new("swift").render_empty_template "#{file_path}/secrets.swift" when "--edit" return if argv_1 == nil exec("dotgpg edit #{argv_1}") when "--usage" puts usage else end end |
#print_options ⇒ Object
85 86 87 |
# File 'lib/mobile-secrets.rb', line 85 def puts "#{header}\n\n#{}" #Wrong action selected end |
#usage ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/mobile-secrets.rb', line 37 def usage usage = "" usage << "1) Create gpg first with --init-gpg \".\"\n" usage << "2) Create a template for MobileSecrets with --create-template\n" usage << "3) Configure MobileSecrets.yml with your hash key, secrets etc\n" usage << "4) Import edited template to encrypted secret.gpg with --import ./MobileSecrets.yml\n" usage << "5) Export secrets from secrets.gpg to source file with --export and PATH to project\n" usage << "6) Add exported source file to the project\n" end |