class Eco::API::UseCases::DefaultCases::Samples::Sftp class Cli < Eco::API::UseCases::Cli desc "SFTP case: manages remote files that match a file pattern" add_option("-file-pattern-const", "Constant that should be used as a pattern") do |options| pattern_const = SCR.get_arg("-file-pattern-const", with_param: true) options.deep_merge!(sftp: {file_pattern_const: pattern_const}) end add_option("-list", "It lists all the files present in the remote folder for the current environment.") do |options| options.deep_merge!(sftp: {command: :list}) end add_option("-get-last", "It gets the last file present in the remote folder for the current environment.") do |options| options.deep_merge!(sftp: {command: :get_last}) end add_option("-get", "It gets all the files present in the remote folder for the current environment.") do |options| options.deep_merge!(sftp: {command: :get}) end add_option("-archive", "It moves all the files present in the remote folder to the archive subfolder.") do |options| options.deep_merge!(sftp: {command: :archive}) end add_option("-local-folder", "Local folder to pull the remote files to.") do |options| local_folder = SCR.get_file("-local-folder", required: true, should_exist: true) options.deep_merge!(sftp: {local_folder: local_folder}) end add_option("-remote-subfolder", "Remote sub folder to pull the remote files from.") do |options| remote_subfolder = SCR.get_arg("-remote-subfolder", with_param: true) options.deep_merge!(sftp: {remote_subfolder: remote_subfolder}) end add_option("-remote-target-folder", "Overrides -remote-subfolder and -remote-folder.") do |options| remote_target_folder = SCR.get_arg("-remote-target-folder", with_param: true) options.deep_merge!(sftp: {remote_target_folder: remote_target_folder}) end add_option("-remote-folder", "Overrides -remote-folder (but not -remote-subfolder).") do |options| remote_folder = SCR.get_arg("-remote-folder", with_param: true) options.deep_merge!(sftp: {remote_folder: remote_folder}) end end end