@zipify/wysiwyg 1.1.1 → 1.2.1-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/.github/actions/lint-css/action.yaml +1 -3
  2. package/.release-it.json +2 -1
  3. package/dist/cli.js +3 -3
  4. package/dist/wysiwyg.css +24 -25
  5. package/dist/wysiwyg.mjs +641 -618
  6. package/jest.config.js +3 -0
  7. package/lib/components/base/Modal.vue +21 -2
  8. package/lib/components/base/__tests__/Modal.test.js +1 -0
  9. package/lib/components/toolbar/controls/link/LinkControl.vue +22 -10
  10. package/lib/components/toolbar/controls/link/LinkControlHeader.vue +3 -3
  11. package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +8 -8
  12. package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +1 -1
  13. package/lib/components/toolbar/controls/link/composables/useLink.js +10 -6
  14. package/lib/composables/__tests__/__snapshots__/useEditor.test.js.snap +1 -1
  15. package/lib/composables/useEditor.js +4 -3
  16. package/lib/enums/TextSettings.js +2 -0
  17. package/lib/extensions/FontStyle.js +2 -2
  18. package/lib/extensions/FontWeight.js +2 -0
  19. package/lib/extensions/Link.js +13 -15
  20. package/lib/extensions/StylePreset.js +33 -3
  21. package/lib/extensions/TextDecoration.js +6 -12
  22. package/lib/extensions/__tests__/FontFamily.test.js +7 -6
  23. package/lib/extensions/__tests__/FontWeight.test.js +19 -10
  24. package/lib/extensions/__tests__/StylePreset.test.js +52 -2
  25. package/lib/extensions/__tests__/TextDecoration.test.js +11 -40
  26. package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +2 -2
  27. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +1 -1
  28. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +1 -1
  29. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +19 -1
  30. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +2 -2
  31. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +17 -1
  32. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +26 -1
  33. package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +2 -2
  34. package/lib/extensions/__tests__/__snapshots__/Margin.test.js.snap +2 -2
  35. package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +22 -2
  36. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +3 -46
  37. package/package.json +22 -22
  38. package/lib/components/toolbar/controls/link/LinkControlApply.vue +0 -35
  39. package/node_modules_lambda/acorn-globals/node_modules/.bin/acorn +0 -4
  40. package/node_modules_lambda/acorn-globals/node_modules/acorn/CHANGELOG.md +0 -620
  41. package/node_modules_lambda/acorn-globals/node_modules/acorn/LICENSE +0 -21
  42. package/node_modules_lambda/acorn-globals/node_modules/acorn/README.md +0 -269
  43. package/node_modules_lambda/acorn-globals/node_modules/acorn/bin/acorn +0 -4
  44. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.d.ts +0 -209
  45. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.js +0 -5186
  46. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.js.map +0 -1
  47. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs +0 -5155
  48. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs.d.ts +0 -2
  49. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs.map +0 -1
  50. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/bin.js +0 -64
  51. package/node_modules_lambda/acorn-globals/node_modules/acorn/package.json +0 -35
  52. package/node_modules_lambda/cssstyle/node_modules/cssom/LICENSE.txt +0 -20
  53. package/node_modules_lambda/cssstyle/node_modules/cssom/README.mdown +0 -67
  54. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSDocumentRule.js +0 -39
  55. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSFontFaceRule.js +0 -36
  56. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSHostRule.js +0 -37
  57. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSImportRule.js +0 -132
  58. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSKeyframeRule.js +0 -37
  59. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSKeyframesRule.js +0 -39
  60. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSMediaRule.js +0 -41
  61. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSOM.js +0 -3
  62. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSRule.js +0 -43
  63. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleDeclaration.js +0 -148
  64. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleRule.js +0 -190
  65. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleSheet.js +0 -88
  66. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSSupportsRule.js +0 -36
  67. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSValue.js +0 -43
  68. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSValueExpression.js +0 -344
  69. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/MatcherList.js +0 -62
  70. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/MediaList.js +0 -61
  71. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/StyleSheet.js +0 -17
  72. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/clone.js +0 -82
  73. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/index.js +0 -21
  74. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/parse.js +0 -464
  75. package/node_modules_lambda/cssstyle/node_modules/cssom/package.json +0 -18
  76. package/node_modules_lambda/data-urls/node_modules/whatwg-url/LICENSE.txt +0 -21
  77. package/node_modules_lambda/data-urls/node_modules/whatwg-url/README.md +0 -106
  78. package/node_modules_lambda/data-urls/node_modules/whatwg-url/index.js +0 -27
  79. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/Function.js +0 -42
  80. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URL-impl.js +0 -209
  81. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URL.js +0 -442
  82. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URLSearchParams-impl.js +0 -130
  83. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URLSearchParams.js +0 -472
  84. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/VoidFunction.js +0 -26
  85. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/encoding.js +0 -16
  86. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/infra.js +0 -26
  87. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/percent-encoding.js +0 -142
  88. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/url-state-machine.js +0 -1244
  89. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/urlencoded.js +0 -106
  90. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/utils.js +0 -190
  91. package/node_modules_lambda/data-urls/node_modules/whatwg-url/package.json +0 -58
  92. package/node_modules_lambda/data-urls/node_modules/whatwg-url/webidl2js-wrapper.js +0 -7
  93. package/node_modules_lambda/escodegen/node_modules/estraverse/.jshintrc +0 -16
  94. package/node_modules_lambda/escodegen/node_modules/estraverse/LICENSE.BSD +0 -19
  95. package/node_modules_lambda/escodegen/node_modules/estraverse/README.md +0 -153
  96. package/node_modules_lambda/escodegen/node_modules/estraverse/estraverse.js +0 -805
  97. package/node_modules_lambda/escodegen/node_modules/estraverse/gulpfile.js +0 -70
  98. package/node_modules_lambda/escodegen/node_modules/estraverse/package.json +0 -40
  99. package/node_modules_lambda/escodegen/node_modules/levn/LICENSE +0 -22
  100. package/node_modules_lambda/escodegen/node_modules/levn/README.md +0 -196
  101. package/node_modules_lambda/escodegen/node_modules/levn/lib/cast.js +0 -298
  102. package/node_modules_lambda/escodegen/node_modules/levn/lib/coerce.js +0 -285
  103. package/node_modules_lambda/escodegen/node_modules/levn/lib/index.js +0 -22
  104. package/node_modules_lambda/escodegen/node_modules/levn/lib/parse-string.js +0 -113
  105. package/node_modules_lambda/escodegen/node_modules/levn/lib/parse.js +0 -102
  106. package/node_modules_lambda/escodegen/node_modules/levn/package.json +0 -47
  107. package/node_modules_lambda/escodegen/node_modules/optionator/CHANGELOG.md +0 -56
  108. package/node_modules_lambda/escodegen/node_modules/optionator/LICENSE +0 -22
  109. package/node_modules_lambda/escodegen/node_modules/optionator/README.md +0 -238
  110. package/node_modules_lambda/escodegen/node_modules/optionator/lib/help.js +0 -260
  111. package/node_modules_lambda/escodegen/node_modules/optionator/lib/index.js +0 -465
  112. package/node_modules_lambda/escodegen/node_modules/optionator/lib/util.js +0 -54
  113. package/node_modules_lambda/escodegen/node_modules/optionator/package.json +0 -44
  114. package/node_modules_lambda/escodegen/node_modules/prelude-ls/CHANGELOG.md +0 -99
  115. package/node_modules_lambda/escodegen/node_modules/prelude-ls/LICENSE +0 -22
  116. package/node_modules_lambda/escodegen/node_modules/prelude-ls/README.md +0 -15
  117. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Func.js +0 -65
  118. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/List.js +0 -686
  119. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Num.js +0 -130
  120. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Obj.js +0 -154
  121. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Str.js +0 -92
  122. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/index.js +0 -178
  123. package/node_modules_lambda/escodegen/node_modules/prelude-ls/package.json +0 -52
  124. package/node_modules_lambda/escodegen/node_modules/source-map/CHANGELOG.md +0 -301
  125. package/node_modules_lambda/escodegen/node_modules/source-map/LICENSE +0 -28
  126. package/node_modules_lambda/escodegen/node_modules/source-map/README.md +0 -742
  127. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.debug.js +0 -3234
  128. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.js +0 -3233
  129. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.min.js +0 -2
  130. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.min.js.map +0 -1
  131. package/node_modules_lambda/escodegen/node_modules/source-map/lib/array-set.js +0 -121
  132. package/node_modules_lambda/escodegen/node_modules/source-map/lib/base64-vlq.js +0 -140
  133. package/node_modules_lambda/escodegen/node_modules/source-map/lib/base64.js +0 -67
  134. package/node_modules_lambda/escodegen/node_modules/source-map/lib/binary-search.js +0 -111
  135. package/node_modules_lambda/escodegen/node_modules/source-map/lib/mapping-list.js +0 -79
  136. package/node_modules_lambda/escodegen/node_modules/source-map/lib/quick-sort.js +0 -114
  137. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-map-consumer.js +0 -1145
  138. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-map-generator.js +0 -425
  139. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-node.js +0 -413
  140. package/node_modules_lambda/escodegen/node_modules/source-map/lib/util.js +0 -488
  141. package/node_modules_lambda/escodegen/node_modules/source-map/package.json +0 -73
  142. package/node_modules_lambda/escodegen/node_modules/source-map/source-map.d.ts +0 -98
  143. package/node_modules_lambda/escodegen/node_modules/source-map/source-map.js +0 -8
  144. package/node_modules_lambda/escodegen/node_modules/type-check/LICENSE +0 -22
  145. package/node_modules_lambda/escodegen/node_modules/type-check/README.md +0 -210
  146. package/node_modules_lambda/escodegen/node_modules/type-check/lib/check.js +0 -126
  147. package/node_modules_lambda/escodegen/node_modules/type-check/lib/index.js +0 -16
  148. package/node_modules_lambda/escodegen/node_modules/type-check/lib/parse-type.js +0 -196
  149. package/node_modules_lambda/escodegen/node_modules/type-check/package.json +0 -40
  150. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  151. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/Changelog.md +0 -212
  152. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/LICENSE +0 -21
  153. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/README.md +0 -130
  154. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -597
  155. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/dbcs-data.js +0 -188
  156. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/index.js +0 -23
  157. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/internal.js +0 -198
  158. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
  159. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
  160. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-data.js +0 -179
  161. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
  162. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
  163. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
  164. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
  165. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
  166. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
  167. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -56
  168. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
  169. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf16.js +0 -197
  170. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf32.js +0 -319
  171. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf7.js +0 -290
  172. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/bom-handling.js +0 -52
  173. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/index.d.ts +0 -41
  174. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/index.js +0 -180
  175. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/streams.js +0 -109
  176. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/package.json +0 -44
@@ -1,238 +0,0 @@
1
- # Optionator
2
- <a name="optionator" />
3
-
4
- Optionator is a JavaScript/Node.js option parsing and help generation library used by [eslint](http://eslint.org), [Grasp](http://graspjs.com), [LiveScript](http://livescript.net), [esmangle](https://github.com/estools/esmangle), [escodegen](https://github.com/estools/escodegen), and [many more](https://www.npmjs.com/browse/depended/optionator).
5
-
6
- For an online demo, check out the [Grasp online demo](http://www.graspjs.com/#demo).
7
-
8
- [About](#about) &middot; [Usage](#usage) &middot; [Settings Format](#settings-format) &middot; [Argument Format](#argument-format)
9
-
10
- ## Why?
11
- The problem with other option parsers, such as `yargs` or `minimist`, is they just accept all input, valid or not.
12
- With Optionator, if you mistype an option, it will give you an error (with a suggestion for what you meant).
13
- If you give the wrong type of argument for an option, it will give you an error rather than supplying the wrong input to your application.
14
-
15
- $ cmd --halp
16
- Invalid option '--halp' - perhaps you meant '--help'?
17
-
18
- $ cmd --count str
19
- Invalid value for option 'count' - expected type Int, received value: str.
20
-
21
- Other helpful features include reformatting the help text based on the size of the console, so that it fits even if the console is narrow, and accepting not just an array (eg. process.argv), but a string or object as well, making things like testing much easier.
22
-
23
- ## About
24
- Optionator uses [type-check](https://github.com/gkz/type-check) and [levn](https://github.com/gkz/levn) behind the scenes to cast and verify input according the specified types.
25
-
26
- MIT license. Version 0.8.3
27
-
28
- npm install optionator
29
-
30
- For updates on Optionator, [follow me on twitter](https://twitter.com/gkzahariev).
31
-
32
- Optionator is a Node.js module, but can be used in the browser as well if packed with webpack/browserify.
33
-
34
- ## Usage
35
- `require('optionator');` returns a function. It has one property, `VERSION`, the current version of the library as a string. This function is called with an object specifying your options and other information, see the [settings format section](#settings-format). This in turn returns an object with three properties, `parse`, `parseArgv`, `generateHelp`, and `generateHelpForOption`, which are all functions.
36
-
37
- ```js
38
- var optionator = require('optionator')({
39
- prepend: 'Usage: cmd [options]',
40
- append: 'Version 1.0.0',
41
- options: [{
42
- option: 'help',
43
- alias: 'h',
44
- type: 'Boolean',
45
- description: 'displays help'
46
- }, {
47
- option: 'count',
48
- alias: 'c',
49
- type: 'Int',
50
- description: 'number of things',
51
- example: 'cmd --count 2'
52
- }]
53
- });
54
-
55
- var options = optionator.parseArgv(process.argv);
56
- if (options.help) {
57
- console.log(optionator.generateHelp());
58
- }
59
- ...
60
- ```
61
-
62
- ### parse(input, parseOptions)
63
- `parse` processes the `input` according to your settings, and returns an object with the results.
64
-
65
- ##### arguments
66
- * input - `[String] | Object | String` - the input you wish to parse
67
- * parseOptions - `{slice: Int}` - all options optional
68
- - `slice` specifies how much to slice away from the beginning if the input is an array or string - by default `0` for string, `2` for array (works with `process.argv`)
69
-
70
- ##### returns
71
- `Object` - the parsed options, each key is a camelCase version of the option name (specified in dash-case), and each value is the processed value for that option. Positional values are in an array under the `_` key.
72
-
73
- ##### example
74
- ```js
75
- parse(['node', 't.js', '--count', '2', 'positional']); // {count: 2, _: ['positional']}
76
- parse('--count 2 positional'); // {count: 2, _: ['positional']}
77
- parse({count: 2, _:['positional']}); // {count: 2, _: ['positional']}
78
- ```
79
-
80
- ### parseArgv(input)
81
- `parseArgv` works exactly like `parse`, but only for array input and it slices off the first two elements.
82
-
83
- ##### arguments
84
- * input - `[String]` - the input you wish to parse
85
-
86
- ##### returns
87
- See "returns" section in "parse"
88
-
89
- ##### example
90
- ```js
91
- parseArgv(process.argv);
92
- ```
93
-
94
- ### generateHelp(helpOptions)
95
- `generateHelp` produces help text based on your settings.
96
-
97
- ##### arguments
98
- * helpOptions - `{showHidden: Boolean, interpolate: Object}` - all options optional
99
- - `showHidden` specifies whether to show options with `hidden: true` specified, by default it is `false`
100
- - `interpolate` specify data to be interpolated in `prepend` and `append` text, `{{key}}` is the format - eg. `generateHelp({interpolate:{version: '0.4.2'}})`, will change this `append` text: `Version {{version}}` to `Version 0.4.2`
101
-
102
- ##### returns
103
- `String` - the generated help text
104
-
105
- ##### example
106
- ```js
107
- generateHelp(); /*
108
- "Usage: cmd [options] positional
109
-
110
- -h, --help displays help
111
- -c, --count Int number of things
112
-
113
- Version 1.0.0
114
- "*/
115
- ```
116
-
117
- ### generateHelpForOption(optionName)
118
- `generateHelpForOption` produces expanded help text for the specified with `optionName` option. If an `example` was specified for the option, it will be displayed, and if a `longDescription` was specified, it will display that instead of the `description`.
119
-
120
- ##### arguments
121
- * optionName - `String` - the name of the option to display
122
-
123
- ##### returns
124
- `String` - the generated help text for the option
125
-
126
- ##### example
127
- ```js
128
- generateHelpForOption('count'); /*
129
- "-c, --count Int
130
- description: number of things
131
- example: cmd --count 2
132
- "*/
133
- ```
134
-
135
- ## Settings Format
136
- When your `require('optionator')`, you get a function that takes in a settings object. This object has the type:
137
-
138
- {
139
- prepend: String,
140
- append: String,
141
- options: [{heading: String} | {
142
- option: String,
143
- alias: [String] | String,
144
- type: String,
145
- enum: [String],
146
- default: String,
147
- restPositional: Boolean,
148
- required: Boolean,
149
- overrideRequired: Boolean,
150
- dependsOn: [String] | String,
151
- concatRepeatedArrays: Boolean | (Boolean, Object),
152
- mergeRepeatedObjects: Boolean,
153
- description: String,
154
- longDescription: String,
155
- example: [String] | String
156
- }],
157
- helpStyle: {
158
- aliasSeparator: String,
159
- typeSeparator: String,
160
- descriptionSeparator: String,
161
- initialIndent: Int,
162
- secondaryIndent: Int,
163
- maxPadFactor: Number
164
- },
165
- mutuallyExclusive: [[String | [String]]],
166
- concatRepeatedArrays: Boolean | (Boolean, Object), // deprecated, set in defaults object
167
- mergeRepeatedObjects: Boolean, // deprecated, set in defaults object
168
- positionalAnywhere: Boolean,
169
- typeAliases: Object,
170
- defaults: Object
171
- }
172
-
173
- All of the properties are optional (the `Maybe` has been excluded for brevities sake), except for having either `heading: String` or `option: String` in each object in the `options` array.
174
-
175
- ### Top Level Properties
176
- * `prepend` is an optional string to be placed before the options in the help text
177
- * `append` is an optional string to be placed after the options in the help text
178
- * `options` is a required array specifying your options and headings, the options and headings will be displayed in the order specified
179
- * `helpStyle` is an optional object which enables you to change the default appearance of some aspects of the help text
180
- * `mutuallyExclusive` is an optional array of arrays of either strings or arrays of strings. The top level array is a list of rules, each rule is a list of elements - each element can be either a string (the name of an option), or a list of strings (a group of option names) - there will be an error if more than one element is present
181
- * `concatRepeatedArrays` see description under the "Option Properties" heading - use at the top level is deprecated, if you want to set this for all options, use the `defaults` property
182
- * `mergeRepeatedObjects` see description under the "Option Properties" heading - use at the top level is deprecated, if you want to set this for all options, use the `defaults` property
183
- * `positionalAnywhere` is an optional boolean (defaults to `true`) - when `true` it allows positional arguments anywhere, when `false`, all arguments after the first positional one are taken to be positional as well, even if they look like a flag. For example, with `positionalAnywhere: false`, the arguments `--flag --boom 12 --crack` would have two positional arguments: `12` and `--crack`
184
- * `typeAliases` is an optional object, it allows you to set aliases for types, eg. `{Path: 'String'}` would allow you to use the type `Path` as an alias for the type `String`
185
- * `defaults` is an optional object following the option properties format, which specifies default values for all options. A default will be overridden if manually set. For example, you can do `default: { type: "String" }` to set the default type of all options to `String`, and then override that default in an individual option by setting the `type` property
186
-
187
- #### Heading Properties
188
- * `heading` a required string, the name of the heading
189
-
190
- #### Option Properties
191
- * `option` the required name of the option - use dash-case, without the leading dashes
192
- * `alias` is an optional string or array of strings which specify any aliases for the option
193
- * `type` is a required string in the [type check](https://github.com/gkz/type-check) [format](https://github.com/gkz/type-check#type-format), this will be used to cast the inputted value and validate it
194
- * `enum` is an optional array of strings, each string will be parsed by [levn](https://github.com/gkz/levn) - the argument value must be one of the resulting values - each potential value must validate against the specified `type`
195
- * `default` is a optional string, which will be parsed by [levn](https://github.com/gkz/levn) and used as the default value if none is set - the value must validate against the specified `type`
196
- * `restPositional` is an optional boolean - if set to `true`, everything after the option will be taken to be a positional argument, even if it looks like a named argument
197
- * `required` is an optional boolean - if set to `true`, the option parsing will fail if the option is not defined
198
- * `overrideRequired` is a optional boolean - if set to `true` and the option is used, and there is another option which is required but not set, it will override the need for the required option and there will be no error - this is useful if you have required options and want to use `--help` or `--version` flags
199
- * `concatRepeatedArrays` is an optional boolean or tuple with boolean and options object (defaults to `false`) - when set to `true` and an option contains an array value and is repeated, the subsequent values for the flag will be appended rather than overwriting the original value - eg. option `g` of type `[String]`: `-g a -g b -g c,d` will result in `['a','b','c','d']`
200
-
201
- You can supply an options object by giving the following value: `[true, options]`. The one currently supported option is `oneValuePerFlag`, this only allows one array value per flag. This is useful if your potential values contain a comma.
202
- * `mergeRepeatedObjects` is an optional boolean (defaults to `false`) - when set to `true` and an option contains an object value and is repeated, the subsequent values for the flag will be merged rather than overwriting the original value - eg. option `g` of type `Object`: `-g a:1 -g b:2 -g c:3,d:4` will result in `{a: 1, b: 2, c: 3, d: 4}`
203
- * `dependsOn` is an optional string or array of strings - if simply a string (the name of another option), it will make sure that that other option is set, if an array of strings, depending on whether `'and'` or `'or'` is first, it will either check whether all (`['and', 'option-a', 'option-b']`), or at least one (`['or', 'option-a', 'option-b']`) other options are set
204
- * `description` is an optional string, which will be displayed next to the option in the help text
205
- * `longDescription` is an optional string, it will be displayed instead of the `description` when `generateHelpForOption` is used
206
- * `example` is an optional string or array of strings with example(s) for the option - these will be displayed when `generateHelpForOption` is used
207
-
208
- #### Help Style Properties
209
- * `aliasSeparator` is an optional string, separates multiple names from each other - default: ' ,'
210
- * `typeSeparator` is an optional string, separates the type from the names - default: ' '
211
- * `descriptionSeparator` is an optional string , separates the description from the padded name and type - default: ' '
212
- * `initialIndent` is an optional int - the amount of indent for options - default: 2
213
- * `secondaryIndent` is an optional int - the amount of indent if wrapped fully (in addition to the initial indent) - default: 4
214
- * `maxPadFactor` is an optional number - affects the default level of padding for the names/type, it is multiplied by the average of the length of the names/type - default: 1.5
215
-
216
- ## Argument Format
217
- At the highest level there are two types of arguments: named, and positional.
218
-
219
- Name arguments of any length are prefixed with `--` (eg. `--go`), and those of one character may be prefixed with either `--` or `-` (eg. `-g`).
220
-
221
- There are two types of named arguments: boolean flags (eg. `--problemo`, `-p`) which take no value and result in a `true` if they are present, the falsey `undefined` if they are not present, or `false` if present and explicitly prefixed with `no` (eg. `--no-problemo`). Named arguments with values (eg. `--tseries 800`, `-t 800`) are the other type. If the option has a type `Boolean` it will automatically be made into a boolean flag. Any other type results in a named argument that takes a value.
222
-
223
- For more information about how to properly set types to get the value you want, take a look at the [type check](https://github.com/gkz/type-check) and [levn](https://github.com/gkz/levn) pages.
224
-
225
- You can group single character arguments that use a single `-`, however all except the last must be boolean flags (which take no value). The last may be a boolean flag, or an argument which takes a value - eg. `-ba 2` is equivalent to `-b -a 2`.
226
-
227
- Positional arguments are all those values which do not fall under the above - they can be anywhere, not just at the end. For example, in `cmd -b one -a 2 two` where `b` is a boolean flag, and `a` has the type `Number`, there are two positional arguments, `one` and `two`.
228
-
229
- Everything after an `--` is positional, even if it looks like a named argument.
230
-
231
- You may optionally use `=` to separate option names from values, for example: `--count=2`.
232
-
233
- If you specify the option `NUM`, then any argument using a single `-` followed by a number will be valid and will set the value of `NUM`. Eg. `-2` will be parsed into `NUM: 2`.
234
-
235
- If duplicate named arguments are present, the last one will be taken.
236
-
237
- ## Technical About
238
- `optionator` is written in [LiveScript](http://livescript.net/) - a language that compiles to JavaScript. It uses [levn](https://github.com/gkz/levn) to cast arguments to their specified type, and uses [type-check](https://github.com/gkz/type-check) to validate values. It also uses the [prelude.ls](http://preludels.com/) library.
@@ -1,260 +0,0 @@
1
- // Generated by LiveScript 1.6.0
2
- (function(){
3
- var ref$, id, find, sort, min, max, map, unlines, nameToRaw, dasherize, naturalJoin, wordWrap, wordwrap, getPreText, setHelpStyleDefaults, generateHelpForOption, generateHelp;
4
- ref$ = require('prelude-ls'), id = ref$.id, find = ref$.find, sort = ref$.sort, min = ref$.min, max = ref$.max, map = ref$.map, unlines = ref$.unlines;
5
- ref$ = require('./util'), nameToRaw = ref$.nameToRaw, dasherize = ref$.dasherize, naturalJoin = ref$.naturalJoin;
6
- wordWrap = require('word-wrap');
7
- wordwrap = function(a, b){
8
- var ref$, indent, width;
9
- ref$ = b === undefined
10
- ? ['', a - 1]
11
- : [repeatString$(' ', a), b - a - 1], indent = ref$[0], width = ref$[1];
12
- return function(text){
13
- return wordWrap(text, {
14
- indent: indent,
15
- width: width,
16
- trim: true
17
- });
18
- };
19
- };
20
- getPreText = function(option, arg$, maxWidth){
21
- var mainName, shortNames, ref$, longNames, type, description, aliasSeparator, typeSeparator, initialIndent, names, namesString, namesStringLen, typeSeparatorString, typeSeparatorStringLen, wrap;
22
- mainName = option.option, shortNames = (ref$ = option.shortNames) != null
23
- ? ref$
24
- : [], longNames = (ref$ = option.longNames) != null
25
- ? ref$
26
- : [], type = option.type, description = option.description;
27
- aliasSeparator = arg$.aliasSeparator, typeSeparator = arg$.typeSeparator, initialIndent = arg$.initialIndent;
28
- if (option.negateName) {
29
- mainName = "no-" + mainName;
30
- if (longNames) {
31
- longNames = map(function(it){
32
- return "no-" + it;
33
- }, longNames);
34
- }
35
- }
36
- names = mainName.length === 1
37
- ? [mainName].concat(shortNames, longNames)
38
- : shortNames.concat([mainName], longNames);
39
- namesString = map(nameToRaw, names).join(aliasSeparator);
40
- namesStringLen = namesString.length;
41
- typeSeparatorString = mainName === 'NUM' ? '::' : typeSeparator;
42
- typeSeparatorStringLen = typeSeparatorString.length;
43
- if (maxWidth != null && !option.boolean && initialIndent + namesStringLen + typeSeparatorStringLen + type.length > maxWidth) {
44
- wrap = wordwrap(initialIndent + namesStringLen + typeSeparatorStringLen, maxWidth);
45
- return namesString + "" + typeSeparatorString + wrap(type).replace(/^\s+/, '');
46
- } else {
47
- return namesString + "" + (option.boolean
48
- ? ''
49
- : typeSeparatorString + "" + type);
50
- }
51
- };
52
- setHelpStyleDefaults = function(helpStyle){
53
- helpStyle.aliasSeparator == null && (helpStyle.aliasSeparator = ', ');
54
- helpStyle.typeSeparator == null && (helpStyle.typeSeparator = ' ');
55
- helpStyle.descriptionSeparator == null && (helpStyle.descriptionSeparator = ' ');
56
- helpStyle.initialIndent == null && (helpStyle.initialIndent = 2);
57
- helpStyle.secondaryIndent == null && (helpStyle.secondaryIndent = 4);
58
- helpStyle.maxPadFactor == null && (helpStyle.maxPadFactor = 1.5);
59
- };
60
- generateHelpForOption = function(getOption, arg$){
61
- var stdout, helpStyle, ref$;
62
- stdout = arg$.stdout, helpStyle = (ref$ = arg$.helpStyle) != null
63
- ? ref$
64
- : {};
65
- setHelpStyleDefaults(helpStyle);
66
- return function(optionName){
67
- var maxWidth, wrap, option, e, pre, defaultString, restPositionalString, description, fullDescription, that, preDescription, descriptionString, exampleString, examples, seperator;
68
- maxWidth = stdout != null && stdout.isTTY ? stdout.columns - 1 : null;
69
- wrap = maxWidth ? wordwrap(maxWidth) : id;
70
- try {
71
- option = getOption(dasherize(optionName));
72
- } catch (e$) {
73
- e = e$;
74
- return e.message;
75
- }
76
- pre = getPreText(option, helpStyle);
77
- defaultString = option['default'] && !option.negateName ? "\ndefault: " + option['default'] : '';
78
- restPositionalString = option.restPositional ? 'Everything after this option is considered a positional argument, even if it looks like an option.' : '';
79
- description = option.longDescription || option.description && sentencize(option.description);
80
- fullDescription = description && restPositionalString
81
- ? description + " " + restPositionalString
82
- : (that = description || restPositionalString) ? that : '';
83
- preDescription = 'description:';
84
- descriptionString = !fullDescription
85
- ? ''
86
- : maxWidth && fullDescription.length - 1 - preDescription.length > maxWidth
87
- ? "\n" + preDescription + "\n" + wrap(fullDescription)
88
- : "\n" + preDescription + " " + fullDescription;
89
- exampleString = (that = option.example) ? (examples = [].concat(that), examples.length > 1
90
- ? "\nexamples:\n" + unlines(examples)
91
- : "\nexample: " + examples[0]) : '';
92
- seperator = defaultString || descriptionString || exampleString ? "\n" + repeatString$('=', pre.length) : '';
93
- return pre + "" + seperator + defaultString + descriptionString + exampleString;
94
- };
95
- };
96
- generateHelp = function(arg$){
97
- var options, prepend, append, helpStyle, ref$, stdout, aliasSeparator, typeSeparator, descriptionSeparator, maxPadFactor, initialIndent, secondaryIndent;
98
- options = arg$.options, prepend = arg$.prepend, append = arg$.append, helpStyle = (ref$ = arg$.helpStyle) != null
99
- ? ref$
100
- : {}, stdout = arg$.stdout;
101
- setHelpStyleDefaults(helpStyle);
102
- aliasSeparator = helpStyle.aliasSeparator, typeSeparator = helpStyle.typeSeparator, descriptionSeparator = helpStyle.descriptionSeparator, maxPadFactor = helpStyle.maxPadFactor, initialIndent = helpStyle.initialIndent, secondaryIndent = helpStyle.secondaryIndent;
103
- return function(arg$){
104
- var ref$, showHidden, interpolate, maxWidth, output, out, data, optionCount, totalPreLen, preLens, i$, len$, item, that, pre, descParts, desc, preLen, sortedPreLens, maxPreLen, preLenMean, x, padAmount, descSepLen, fullWrapCount, partialWrapCount, descLen, totalLen, initialSpace, wrapAllFull, i, wrap;
105
- ref$ = arg$ != null
106
- ? arg$
107
- : {}, showHidden = ref$.showHidden, interpolate = ref$.interpolate;
108
- maxWidth = stdout != null && stdout.isTTY ? stdout.columns - 1 : null;
109
- output = [];
110
- out = function(it){
111
- return output.push(it != null ? it : '');
112
- };
113
- if (prepend) {
114
- out(interpolate ? interp(prepend, interpolate) : prepend);
115
- out();
116
- }
117
- data = [];
118
- optionCount = 0;
119
- totalPreLen = 0;
120
- preLens = [];
121
- for (i$ = 0, len$ = (ref$ = options).length; i$ < len$; ++i$) {
122
- item = ref$[i$];
123
- if (showHidden || !item.hidden) {
124
- if (that = item.heading) {
125
- data.push({
126
- type: 'heading',
127
- value: that
128
- });
129
- } else {
130
- pre = getPreText(item, helpStyle, maxWidth);
131
- descParts = [];
132
- if ((that = item.description) != null) {
133
- descParts.push(that);
134
- }
135
- if (that = item['enum']) {
136
- descParts.push("either: " + naturalJoin(that));
137
- }
138
- if (item['default'] && !item.negateName) {
139
- descParts.push("default: " + item['default']);
140
- }
141
- desc = descParts.join(' - ');
142
- data.push({
143
- type: 'option',
144
- pre: pre,
145
- desc: desc,
146
- descLen: desc.length
147
- });
148
- preLen = pre.length;
149
- optionCount++;
150
- totalPreLen += preLen;
151
- preLens.push(preLen);
152
- }
153
- }
154
- }
155
- sortedPreLens = sort(preLens);
156
- maxPreLen = sortedPreLens[sortedPreLens.length - 1];
157
- preLenMean = initialIndent + totalPreLen / optionCount;
158
- x = optionCount > 2 ? min(preLenMean * maxPadFactor, maxPreLen) : maxPreLen;
159
- for (i$ = sortedPreLens.length - 1; i$ >= 0; --i$) {
160
- preLen = sortedPreLens[i$];
161
- if (preLen <= x) {
162
- padAmount = preLen;
163
- break;
164
- }
165
- }
166
- descSepLen = descriptionSeparator.length;
167
- if (maxWidth != null) {
168
- fullWrapCount = 0;
169
- partialWrapCount = 0;
170
- for (i$ = 0, len$ = data.length; i$ < len$; ++i$) {
171
- item = data[i$];
172
- if (item.type === 'option') {
173
- pre = item.pre, desc = item.desc, descLen = item.descLen;
174
- if (descLen === 0) {
175
- item.wrap = 'none';
176
- } else {
177
- preLen = max(padAmount, pre.length) + initialIndent + descSepLen;
178
- totalLen = preLen + descLen;
179
- if (totalLen > maxWidth) {
180
- if (descLen / 2.5 > maxWidth - preLen) {
181
- fullWrapCount++;
182
- item.wrap = 'full';
183
- } else {
184
- partialWrapCount++;
185
- item.wrap = 'partial';
186
- }
187
- } else {
188
- item.wrap = 'none';
189
- }
190
- }
191
- }
192
- }
193
- }
194
- initialSpace = repeatString$(' ', initialIndent);
195
- wrapAllFull = optionCount > 1 && fullWrapCount + partialWrapCount * 0.5 > optionCount * 0.5;
196
- for (i$ = 0, len$ = data.length; i$ < len$; ++i$) {
197
- i = i$;
198
- item = data[i$];
199
- if (item.type === 'heading') {
200
- if (i !== 0) {
201
- out();
202
- }
203
- out(item.value + ":");
204
- } else {
205
- pre = item.pre, desc = item.desc, descLen = item.descLen, wrap = item.wrap;
206
- if (maxWidth != null) {
207
- if (wrapAllFull || wrap === 'full') {
208
- wrap = wordwrap(initialIndent + secondaryIndent, maxWidth);
209
- out(initialSpace + "" + pre + "\n" + wrap(desc));
210
- continue;
211
- } else if (wrap === 'partial') {
212
- wrap = wordwrap(initialIndent + descSepLen + max(padAmount, pre.length), maxWidth);
213
- out(initialSpace + "" + pad(pre, padAmount) + descriptionSeparator + wrap(desc).replace(/^\s+/, ''));
214
- continue;
215
- }
216
- }
217
- if (descLen === 0) {
218
- out(initialSpace + "" + pre);
219
- } else {
220
- out(initialSpace + "" + pad(pre, padAmount) + descriptionSeparator + desc);
221
- }
222
- }
223
- }
224
- if (append) {
225
- out();
226
- out(interpolate ? interp(append, interpolate) : append);
227
- }
228
- return unlines(output);
229
- };
230
- };
231
- function pad(str, num){
232
- var len, padAmount;
233
- len = str.length;
234
- padAmount = num - len;
235
- return str + "" + repeatString$(' ', padAmount > 0 ? padAmount : 0);
236
- }
237
- function sentencize(str){
238
- var first, rest, period;
239
- first = str.charAt(0).toUpperCase();
240
- rest = str.slice(1);
241
- period = /[\.!\?]$/.test(str) ? '' : '.';
242
- return first + "" + rest + period;
243
- }
244
- function interp(string, object){
245
- return string.replace(/{{([a-zA-Z$_][a-zA-Z$_0-9]*)}}/g, function(arg$, key){
246
- var ref$;
247
- return (ref$ = object[key]) != null
248
- ? ref$
249
- : "{{" + key + "}}";
250
- });
251
- }
252
- module.exports = {
253
- generateHelp: generateHelp,
254
- generateHelpForOption: generateHelpForOption
255
- };
256
- function repeatString$(str, n){
257
- for (var r = ''; n > 0; (n >>= 1) && (str += str)) if (n & 1) r += str;
258
- return r;
259
- }
260
- }).call(this);