dry-cli/docsite/source/file-utilities.html.md

3.2 KiB

title layout name
File Utilities gem-single dry-cli

File utilities are a set of useful methods to manipulate files and directories, which must be required manually. API doc

require 'dry/cli/utils/files'

List of implemented commands

  • append - adds a new line at the bottom of the file;
  • cp - copies source into destination;
  • delete - deletes given path (file);
  • delete_directory - deletes given path (directory);
  • directory? - checks if path is a directory;
  • exist? - checks if path exist;
  • inject_line_after - inject contents in path after target;
  • inject_line_after_last - inject contents in path after last target;
  • inject_line_before - inject contents in path before target;
  • inject_line_before_last - inject contents in path after last target;
  • mkdir - creates a directory for the given path;
  • mkdir_p - creates a directory for the given path;
  • remove_block - removes target block from path;
  • remove_line - removes line from path, matching target;
  • replace_first_line - replace first line in path that contains target with replacement;
  • replace_last_line - replace last line in path that contains target with replacement;
  • touch - creates an empty file for the given path;
  • unshift - adds a new line at the top of the file;
  • write - creates a new file or rewrites the contents of an existing file for the given path and content All the intermediate directories are created;

You can find more information in API doc.