Skip to content

Commit

Permalink
Merge pull request #4 from cto-af/update
Browse files Browse the repository at this point in the history
update linewrap version, use new defaults
  • Loading branch information
hildjj committed Jun 11, 2023
2 parents 4472812 + 9baa025 commit 6147636
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 18 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ Options:
indent? Default: false
--isNewline <regex> a regular expression to replace newlines in the
input. Empty to leave newlines in place.
Default: "[^\\S\\r\\n\\v\\f\\x85\\u2028\
\u2029]*[\\r\\n\\v\\f\\x85\\u2028\\u2029]+\\s*"
-l,--locale <iso location> locale for grapheme segmentation. Has very
little effect at the moment
--newline <string> how to separate the lines of output Default:
"\n"
--newlineReplacement <string> when isNewline matches, replace with this
string Default: " "
-o,--outFile <file> output to a file instead of stdout
--outdentFirst Do not indent the first output line
--outdentFirst Do not indent the first output line Default:
false
--overflow <style> what to do with words that are longer than
width. (choices: "visible", "clip",
"anywhere") Default: "visible"
Expand All @@ -68,7 +71,8 @@ Options:
be specified multiple times. Default: []
-v,--verbose turn on super-verbose information. Not useful
for anything but debugging underlying libraries
-w,--width <columns> maximum line length Default: "80"
-w,--width <columns> maximum line length Default: "(your terminal
width or 80)"
```

## Examples
Expand Down
14 changes: 9 additions & 5 deletions bin/linewrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const config = {
},
ellipsis: {
type: 'string',
default: '\u{2026}',
default: LineWrap.DEFAULT_OPTIONS.ellipsis,
argumentName: 'string',
description: 'What string to use when a word is longer than the max width, and in overflow mode "clip"',
},
Expand All @@ -41,7 +41,7 @@ const config = {
html: {type: 'boolean', description: 'escape output for HTML'},
hyphen: {
type: 'string',
default: '-',
default: LineWrap.DEFAULT_OPTIONS.hyphen,
argumentName: 'string',
description: 'What string to use when a word is longer than the max width, and in overflow mode "any"',
},
Expand All @@ -54,23 +54,26 @@ const config = {
},
indentChar: {
type: 'string',
default: ' ',
default: LineWrap.DEFAULT_OPTIONS.indentChar,
argumentName: 'string',
description: 'if indent is a number, that many indentChars will be inserted before each line',
},
indentEmpty: {
type: 'boolean',
default: false,
default: LineWrap.DEFAULT_OPTIONS.indentEmpty,
description: 'if the input string is empty, should we still indent?',
},
isNewline: {
type: 'string',
default: LineWrap.DEFAULT_OPTIONS.isNewline.source,
argumentName: 'regex',
description: 'a regular expression to replace newlines in the input. Empty to leave newlines in place.',
},
locale: {
short: 'l',
type: 'string',
// This would make the tests depend on current locale:
// default: LineWrap.DEFAULT_OPTIONS.locale,
argumentName: 'iso location',
description: 'locale for grapheme segmentation. Has very little effect at the moment',
},
Expand All @@ -83,11 +86,12 @@ const config = {
newlineReplacement: {
type: 'string',
argumentName: 'string',
default: ' ',
default: LineWrap.DEFAULT_OPTIONS.newlineReplacement,
description: 'when isNewline matches, replace with this string',
},
outdentFirst: {
type: 'boolean',
default: !LineWrap.DEFAULT_OPTIONS.indentFirst,
description: 'Do not indent the first output line',
},
outFile: {
Expand Down
27 changes: 19 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
"license": "MIT",
"repository": "cto-af/linewrap-cli",
"dependencies": {
"@cto.af/linewrap": "1.0.2",
"@cto.af/linewrap": "1.0.3",
"minus-h": "1.1.1"
},
"devDependencies": {
"@cto.af/eslint-config": "1.1.2",
"@types/node": "20.2.5",
"@types/node": "20.3.0",
"c8": "7.14.0",
"eslint": "8.42.0",
"mocha": "10.2.0"
Expand Down
5 changes: 4 additions & 1 deletion test/bin.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,17 @@ const HELP = [
' indent? Default: false',
' --isNewline <regex> a regular expression to replace newlines in the',
' input. Empty to leave newlines in place.',
' Default: "[^\\\\S\\\\r\\\\n\\\\v\\\\f\\\\x85\\\\u2028\\',
' \\u2029]*[\\\\r\\\\n\\\\v\\\\f\\\\x85\\\\u2028\\\\u2029]+\\\\s*"',
' -l,--locale <iso location> locale for grapheme segmentation. Has very',
' little effect at the moment',
' --newline <string> how to separate the lines of output Default:',
' "\\n"',
' --newlineReplacement <string> when isNewline matches, replace with this',
' string Default: " "',
' -o,--outFile <file> output to a file instead of stdout',
' --outdentFirst Do not indent the first output line',
' --outdentFirst Do not indent the first output line Default:',
' false',
' --overflow <style> what to do with words that are longer than',
' width. (choices: "visible", "clip",',
' "anywhere") Default: "visible"',
Expand Down

0 comments on commit 6147636

Please sign in to comment.