3.2 KiB
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
inpath
aftertarget
; - inject_line_after_last - inject
contents
inpath
after lasttarget
; - inject_line_before - inject
contents
inpath
beforetarget
; - inject_line_before_last - inject
contents
inpath
after lasttarget
; - mkdir - creates a directory for the given path;
- mkdir_p - creates a directory for the given path;
- remove_block - removes
target
block frompath
; - remove_line - removes line from
path
, matchingtarget
; - replace_first_line - replace first line in
path
that containstarget
withreplacement
; - replace_last_line - replace last line in
path
that containstarget
withreplacement
; - 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.