@nan0web/ui 1.0.2 → 1.0.3
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.
- package/README.md +2 -35
- package/package.json +7 -2
- package/src/App/Core/CoreApp.js +14 -19
- package/src/App/Core/UI.js +5 -5
- package/src/App/User/UserApp.js +4 -19
- package/src/App/User/UserUI.js +4 -4
- package/src/App/User/index.js +0 -6
- package/src/App/index.js +0 -3
- package/src/README.md.js +3 -27
- package/src/StdIn.js +1 -3
- package/src/core/Error/index.js +9 -0
- package/src/core/Form/Form.js +36 -18
- package/src/core/Form/Input.js +16 -7
- package/src/core/Form/Message.js +6 -9
- package/src/core/InputAdapter.js +4 -0
- package/src/core/Message/InputMessage.js +11 -11
- package/src/core/Message/OutputMessage.js +1 -1
- package/src/core/index.js +2 -0
- package/src/index.js +1 -0
- package/types/App/Core/CoreApp.d.ts +9 -9
- package/types/App/Core/UI.d.ts +5 -5
- package/types/App/Core/Widget.d.ts +1 -1
- package/types/App/User/Command/Message.d.ts +2 -3
- package/types/App/User/Command/Options.d.ts +9 -2
- package/types/App/User/Command/index.d.ts +1 -4
- package/types/App/User/UserApp.d.ts +10 -7
- package/types/App/User/UserUI.d.ts +0 -9
- package/types/App/User/index.d.ts +0 -4
- package/types/App/index.d.ts +1 -3
- package/types/Frame/Frame.d.ts +5 -5
- package/types/View/View.d.ts +3 -3
- package/types/core/Error/index.d.ts +6 -0
- package/types/core/Form/Form.d.ts +12 -6
- package/types/core/Form/Input.d.ts +20 -7
- package/types/core/Form/Message.d.ts +10 -4
- package/types/core/InputAdapter.d.ts +2 -0
- package/types/core/Message/InputMessage.d.ts +5 -5
- package/types/core/Message/OutputMessage.d.ts +1 -1
- package/types/core/Stream.d.ts +1 -1
- package/types/core/StreamEntry.d.ts +1 -1
- package/types/core/index.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/src/App/Command/Options.js +0 -78
- package/src/App/Command/index.js +0 -9
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Represents command options with default values.
|
|
3
|
-
* Provides utilities for handling command line options.
|
|
4
|
-
*/
|
|
5
|
-
class CommandOptions {
|
|
6
|
-
/**
|
|
7
|
-
* Default option values.
|
|
8
|
-
* @type {object}
|
|
9
|
-
* @property {boolean} help - Whether help is requested
|
|
10
|
-
* @property {string} cwd - Current working directory
|
|
11
|
-
*/
|
|
12
|
-
static DEFAULTS = {
|
|
13
|
-
help: false,
|
|
14
|
-
cwd: "",
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/** @type {boolean} Whether help is requested */
|
|
18
|
-
help
|
|
19
|
-
|
|
20
|
-
/** @type {string} Current working directory */
|
|
21
|
-
cwd
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new CommandOptions instance.
|
|
25
|
-
* @param {object} props - The properties for command options
|
|
26
|
-
* @param {boolean} [props.help=false] - Whether help is requested
|
|
27
|
-
* @param {string} [props.cwd=""] - Current working directory
|
|
28
|
-
*/
|
|
29
|
-
constructor(props = {}) {
|
|
30
|
-
const {
|
|
31
|
-
help = CommandOptions.DEFAULTS.help,
|
|
32
|
-
cwd = CommandOptions.DEFAULTS.cwd,
|
|
33
|
-
} = props
|
|
34
|
-
this.help = Boolean(help)
|
|
35
|
-
this.cwd = String(cwd)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/** @type {Record<string, any>} */
|
|
39
|
-
get DEFAULTS() {
|
|
40
|
-
return /** @type {typeof CommandOptions} */ (this.constructor).DEFAULTS
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Checks if all options have their default values.
|
|
45
|
-
* @returns {boolean} True if all options are at their default values, false otherwise
|
|
46
|
-
*/
|
|
47
|
-
get empty() {
|
|
48
|
-
return Object.entries(this).every(
|
|
49
|
-
([key, value]) => CommandOptions.DEFAULTS[key] === value
|
|
50
|
-
)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Converts the options to a string representation.
|
|
55
|
-
* @returns {string} String representation of the options or "<no options>" if none set
|
|
56
|
-
*/
|
|
57
|
-
toString() {
|
|
58
|
-
const opts = Object.entries(this).map(([key, value]) => {
|
|
59
|
-
if (this.DEFAULTS[key] === value) return false
|
|
60
|
-
const prefix = true === value ? "--" : "-"
|
|
61
|
-
return `${prefix}${key}${value ? ` ${value}` : ""}`
|
|
62
|
-
}).filter(Boolean)
|
|
63
|
-
if (0 === opts.length) return "<no options>"
|
|
64
|
-
return opts.join(" ")
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Creates a CommandOptions instance from the given props.
|
|
69
|
-
* @param {CommandOptions|object} props - The properties to create from
|
|
70
|
-
* @returns {CommandOptions} A CommandOptions instance
|
|
71
|
-
*/
|
|
72
|
-
static from(props) {
|
|
73
|
-
if (props instanceof CommandOptions) return props
|
|
74
|
-
return new this(props)
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default CommandOptions
|