Top Level Namespace
- Includes:
- Fox
Defined Under Namespace
Modules: Bitferry Classes: Output, UI
Constant Summary collapse
- Endpoint =
%{ The endpoint may be one of: * directory -- absolute or relative local directory (/data, ../source, c:\\data) * local:directory, :directory -- absolute local directory (:/data, local:c:\\data) * :tag:directory -- path relative to the intact volume matched by (partial) tag (:fa2c:source/data) The former case resolves specified directory againt an intact volume to make it volume-relative. It is an error if there is no intact volume that encompasses specified directory. The local: directory is left as is (not resolved against volumes). The :tag: directory is bound to the specified volume. }
- Encryption =
%{ The encryption mode is controlled by --encrypt or --decrypt options. The mandatory password will be read from the standard input channel (pipe or keyboard). }
Instance Method Summary collapse
- #bitferry(&code) ⇒ Object
- #create_rclone_task(task, *args, **opts) ⇒ Object
- #ext_globs(exts) ⇒ Object
- #obtain_password ⇒ Object
- #setup_rclone_task(x) ⇒ Object
- #setup_task(x, include: true) ⇒ Object
Instance Method Details
#bitferry(&code) ⇒ Object
89 90 91 92 93 94 95 96 97 98 |
# File 'lib/bitferry/cli.rb', line 89 def bitferry(&code) begin Bitferry.restore result = yield exit(Bitferry.commit && result ? 0 : 1) rescue => e Bitferry.log.fatal(e.) exit(1) end end |
#create_rclone_task(task, *args, **opts) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/bitferry/cli.rb', line 79 def create_rclone_task(task, *args, **opts) task.new(*args, process: $process, encryption: $encryption&.new(obtain_password, process: $extended ? :extended : $profile), include: $include.flatten.uniq, exclude: $exclude.flatten.uniq, **opts ) end |
#ext_globs(exts) ⇒ Object
31 |
# File 'lib/bitferry/cli.rb', line 31 def ext_globs(exts) = exts.split(',').collect { |ext| "*.#{ext}" } |
#obtain_password ⇒ Object
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/bitferry/cli.rb', line 101 def obtain_password if $stdin.tty? p1 = IO.console.getpass 'Enter password:' p2 = IO.console.getpass 'Repeat password:' raise 'passwords do not match' unless p1 == p2 p1 else $stdin.readline.strip! end end |
#setup_rclone_task(x) ⇒ Object
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 |
# File 'lib/bitferry/cli.rb', line 50 def setup_rclone_task(x) x.parameter 'SOURCE', 'Source endpoint specifier' x.parameter 'DESTINATION', 'Destination endpoint specifier' x.option '-e', :flag, 'Encrypt files in destination using default profile (alias for -E default)', attribute_name: :e do $encryption = Bitferry::Rclone::Encrypt $profile = :default end x.option '-d', :flag, 'Decrypt source files using default profile (alias for -D default)', attribute_name: :d do $encryption = Bitferry::Rclone::Decrypt $profile = :default end x.option '-u', :flag, 'Apply extended (unicode) encryption profile options (alias for -E extended / -D extended)', attribute_name: :u do $extended = true end x.option ['--process', '-X'], 'OPTIONS', 'Extra task processing profile/options' do |opts| $process = opts end x.option ['--encrypt', '-E'], 'OPTIONS', 'Encrypt files in destination using specified profile/options' do |opts| $encryption = Bitferry::Rclone::Encrypt $profile = opts end x.option ['--decrypt', '-D'], 'OPTIONS', 'Decrypt source files using specified profile/options' do |opts| $encryption = Bitferry::Rclone::Decrypt $profile = opts end setup_task(x) end |
#setup_task(x, include: true) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bitferry/cli.rb', line 34 def setup_task(x, include: true) x.option ['-i'], 'EXTS', 'Include file extensions (comma-separated list)', multivalued: true, attribute_name: :include_exts do |exts| $include << ext_globs(exts) end if include x.option ['-x'], 'EXTS', 'Exclude file extensions (comma-separated list)', multivalued: true, attribute_name: :exclude_exts do |exts| $exclude << ext_globs(exts) end x.option ['--include'], 'GLOBS', 'Include path specifications (comma-separated list)', multivalued: true, attribute_name: :include do |globs| $include << globs.split(',') end if include x.option ['--exclude'], 'GLOBS', 'Exclude path specifications (comma-separated list)', multivalued: true, attribute_name: :exclude do |globs| $exclude << globs.split(',') end end |