Class: Boilercode::Commands::Dotfiles::Find
- Inherits:
-
Boilercode::Command
- Object
- Boilercode::Command
- Boilercode::Commands::Dotfiles::Find
- Defined in:
- lib/boilercode/commands/dotfiles/find.rb
Instance Method Summary collapse
- #execute(input: $stdin, output: $stdout) ⇒ Object
- #file_client(file) ⇒ Object
-
#initialize(options) ⇒ Find
constructor
A new instance of Find.
Methods inherited from Boilercode::Command
#ask, #client, #config, #credentials, #download, #link_to, #logger, #markdown, #open_in_browser, #parse_json, #pastel, #prompt
Constructor Details
#initialize(options) ⇒ Find
Returns a new instance of Find.
9 10 11 |
# File 'lib/boilercode/commands/dotfiles/find.rb', line 9 def initialize() @options = end |
Instance Method Details
#execute(input: $stdin, output: $stdout) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/boilercode/commands/dotfiles/find.rb', line 13 def execute(input: $stdin, output: $stdout) look_in_home_directory = prompt.yes?("Search for dotfiles in home directory or specify a directory?") directory = if look_in_home_directory File.("~") else prompt.ask("Please enter the directory to search for dotfiles") end dotfiles = Dir.glob("#{directory}/.*") # remove . and .. from the list of files dotfiles = dotfiles.reject { |file| file == "." || file == ".." } # remove directories from the list of files dotfiles = dotfiles.reject { |file| File.directory?(file) } files_to_upload = prompt.multi_select("Select dotfiles to upload", dotfiles) files_to_upload.each do |file| file_client(file).upload puts pastel.green "Uploaded #{file}" end output.puts "OK" end |
#file_client(file) ⇒ Object
34 35 36 |
# File 'lib/boilercode/commands/dotfiles/find.rb', line 34 def file_client(file) Boilercode::FileClient.new(file, folder_path: "dotfiles") end |