@oclif/core 1.19.0 → 1.19.2
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 +13 -24
- package/lib/config/config.js +2 -1
- package/lib/flags.js +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,20 +21,20 @@ The [cli-ux README](./src/cli-ux/README.md) also contains detailed usage example
|
|
|
21
21
|
Usage
|
|
22
22
|
=====
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
We strongly encourage you generate an oclif CLI using the [oclif cli](https://github.com/oclif/oclif). The generator will generate an npm package with `@oclif/core` as a dependency.
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
```
|
|
26
|
+
You can, however, use `@oclif/core` in a standalone script like this:
|
|
27
|
+
```typescript
|
|
28
28
|
#!/usr/bin/env ts-node
|
|
29
29
|
|
|
30
30
|
import * as fs from 'fs'
|
|
31
31
|
import {Command, Flags} from '@oclif/core'
|
|
32
32
|
|
|
33
33
|
class LS extends Command {
|
|
34
|
+
static description = 'List the files in a directory.'
|
|
34
35
|
static flags = {
|
|
35
36
|
version: Flags.version(),
|
|
36
37
|
help: Flags.help(),
|
|
37
|
-
// run with --dir= or -d=
|
|
38
38
|
dir: Flags.string({
|
|
39
39
|
char: 'd',
|
|
40
40
|
default: process.cwd(),
|
|
@@ -43,34 +43,23 @@ class LS extends Command {
|
|
|
43
43
|
|
|
44
44
|
async run() {
|
|
45
45
|
const {flags} = await this.parse(LS)
|
|
46
|
-
|
|
47
|
-
for (
|
|
46
|
+
const files = fs.readdirSync(flags.dir)
|
|
47
|
+
for (const f of files) {
|
|
48
48
|
this.log(f)
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
LS.run()
|
|
54
|
-
|
|
53
|
+
LS.run().then(() => {
|
|
54
|
+
require('@oclif/core/flush')
|
|
55
|
+
}, () => {
|
|
56
|
+
require('@oclif/core/handle')
|
|
57
|
+
})
|
|
55
58
|
```
|
|
56
59
|
|
|
57
|
-
Then run
|
|
60
|
+
Then run it like this:
|
|
58
61
|
|
|
59
62
|
```sh-session
|
|
60
|
-
$
|
|
63
|
+
$ ts-node myscript.ts
|
|
61
64
|
...files in current dir...
|
|
62
|
-
$ ./myscript --dir foobar
|
|
63
|
-
...files in ./foobar...
|
|
64
|
-
$ ./myscript --version
|
|
65
|
-
myscript/0.0.0 darwin-x64 node-v9.5.0
|
|
66
|
-
$ ./myscript --help
|
|
67
|
-
USAGE
|
|
68
|
-
$ @oclif/core
|
|
69
|
-
|
|
70
|
-
OPTIONS
|
|
71
|
-
-d, --dir=dir [default: /Users/jdickey/src/github.com/oclif/core]
|
|
72
|
-
--help show CLI help
|
|
73
|
-
--version show CLI version
|
|
74
65
|
```
|
|
75
|
-
|
|
76
|
-
See the [generator](https://github.com/oclif/oclif) for all the options you can pass to the command.
|
package/lib/config/config.js
CHANGED
|
@@ -642,6 +642,7 @@ async function toCached(c, plugin) {
|
|
|
642
642
|
helpGroup: flag.helpGroup,
|
|
643
643
|
allowNo: flag.allowNo,
|
|
644
644
|
dependsOn: flag.dependsOn,
|
|
645
|
+
relationships: flag.relationships,
|
|
645
646
|
exclusive: flag.exclusive,
|
|
646
647
|
deprecated: flag.deprecated,
|
|
647
648
|
aliases: flag.aliases,
|
|
@@ -701,7 +702,7 @@ async function toCached(c, plugin) {
|
|
|
701
702
|
args,
|
|
702
703
|
};
|
|
703
704
|
// do not include these properties in manifest
|
|
704
|
-
const ignoreCommandProperties = ['plugin', '_flags'];
|
|
705
|
+
const ignoreCommandProperties = ['plugin', '_flags', '_enableJsonFlag', '_globalFlags'];
|
|
705
706
|
const stdKeys = Object.keys(stdProperties);
|
|
706
707
|
const keysToAdd = Object.keys(c).filter(property => ![...stdKeys, ...ignoreCommandProperties].includes(property));
|
|
707
708
|
const additionalProperties = {};
|
package/lib/flags.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.help = exports.version = exports.enum = exports._enum = exports.custom = exports.option = exports.build = exports.string = exports.file = exports.directory = exports.url = exports.integer = exports.boolean = void 0;
|
|
4
4
|
const parser_1 = require("./parser");
|
|
5
|
+
const help_1 = require("./help");
|
|
5
6
|
var parser_2 = require("./parser");
|
|
6
7
|
Object.defineProperty(exports, "boolean", { enumerable: true, get: function () { return parser_2.boolean; } });
|
|
7
8
|
Object.defineProperty(exports, "integer", { enumerable: true, get: function () { return parser_2.integer; } });
|
|
@@ -41,7 +42,8 @@ const help = (opts = {}) => {
|
|
|
41
42
|
description: 'Show CLI help.',
|
|
42
43
|
...opts,
|
|
43
44
|
parse: async (_, cmd) => {
|
|
44
|
-
cmd.
|
|
45
|
+
new help_1.Help(cmd.config).showHelp(cmd.argv);
|
|
46
|
+
cmd.exit(0);
|
|
45
47
|
},
|
|
46
48
|
});
|
|
47
49
|
};
|