Skip to content

Commit

Permalink
Exclude files via named params
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasrw committed Jul 28, 2023
1 parent 4eb311b commit 982a4db
Show file tree
Hide file tree
Showing 9 changed files with 1,514 additions and 741 deletions.
8 changes: 8 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
printWidth: 100
tabWidth: 4
useTabs: true
bracketSpacing: false
trailingComma: es5
singleQuote: true
arrowParens: "avoid"

16 changes: 13 additions & 3 deletions bin/ES6/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ const yargs = require('yargs')
'> rexreplace pattern replacement [fileGlob|option]+')
.example(`> rexreplace 'Foo' 'xxx' myfile.md`, `'foobar' in myfile.md will become 'xxxbar'`)
.example('')
.example(`> rr Foo xxx myfile.md`, `The alias 'rr' can be used instead of 'rexreplace'`)
.example(`> rr xxx Foo myfile.md`, `The alias 'rr' can be used instead of 'rexreplace'`)
.example('')
.example(`> rexreplace '(f?(o))o(.*)' '$3$1€2' myfile.md`, `'foobar' in myfile.md will become 'barfoo'`)
.example('')
.example(`> rexreplace '^#' '##' *.md`, `All markdown files in this dir got all headlines moved one level deeper`)
.example('')
.example(`> rexreplace 'a' 'b' 'myfile.md' 'src/**/*.*' `, `Provide multiple files or glob if needed`)
.version('v', 'Print rexreplace version (can be given as only argument)', rexreplace.version)
.alias('v', 'version')
.boolean('V')
Expand Down Expand Up @@ -155,6 +157,12 @@ The following values defaults to \`❌\` if haystack does not originate from a f
All variables, except from module, date objects, \`nl\` and \`_\`, has a corresponding variable name followed by \`_\` where the content has an extra space at the end (for easy concatenation).
`)
.string('x')
.describe('x', 'Exclude files with a path that matches this regular expression. Will follow same regex flags and setup as the main search. Can be used multiple times.')
.alias('x', 'exclude-re')
.string('X')
.describe('X', 'Exclude files found with this glob. Can be used multiple times.')
.alias('X', 'exclude-glob')
/*
.boolean('N')
.alias('N', 'void-newline')
Expand Down Expand Up @@ -183,7 +191,7 @@ All variables, except from module, date objects, \`nl\` and \`_\`, has a corresp
/* // Ideas
.boolean('n')
.describe('n', "Do replacement on file names instead of file content (rename the files)")
.describe('n', "Do replacement on file path/names instead of file content (rename/move the files)")
.alias('n', 'name')
// https://github.com/eugeneware/replacestream
Expand Down Expand Up @@ -241,10 +249,12 @@ function unescapeString(str = '') {
});
let pipeInUse = false;
let pipeData = '';
config.globs = yargs.argv._;
config.pipedData = null;
config.showHelp = yargs.showHelp;
config.pattern = pattern;
config.includeGlob = yargs.argv._;
config.excludeGlob = [...yargs.argv.excludeGlob].filter(Boolean);
config.excludeRe = [...yargs.argv.excludeRe].filter(Boolean);
if (config.replacementJs) {
config.replacement = replacement;
}
Expand Down
Loading

0 comments on commit 982a4db

Please sign in to comment.