Skip to content

Commit

Permalink
[fix] $168 Add help command to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
adamreisnz committed Jul 2, 2024
1 parent dc5e8cd commit d0b8c0d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,24 @@ async function main() {
const argv = yargs(hideBin(process.argv)).argv
const {configFile} = argv

//Display help
if (argv.help || argv.h) {
return console.log(`
Usage:
replace-in-file from to from to some/file.js,some/**/glob.js
Available options (all are optional):
--configFile Path to JSON config file
--ignore Files to ignore (comma separated)
--encoding File encoding (default is utf-8)
--disableGlobs Disable glob expansion
--verbose Show additional information
--quiet Suppress output
--dry Dry run (no changes made)
--help, -h Show this help information
`)
}

//Verify arguments
if (argv._.length < 3 && !configFile) {
throw new Error('Replace in file needs at least 3 arguments')
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "replace-in-file",
"type": "module",
"version": "8.0.3",
"version": "8.1.0",
"description": "A simple utility to quickly replace text in one or more files.",
"homepage": "https://github.com/adamreisnz/replace-in-file#readme",
"author": {
Expand Down

0 comments on commit d0b8c0d

Please sign in to comment.