@oclif/core 1.19.0 → 1.19.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 (3) hide show
  1. package/README.md +13 -24
  2. package/lib/flags.js +3 -1
  3. 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
- Without the generator, you can create a simple CLI like this:
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
- **TypeScript**
27
- ```js
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
- let files = fs.readdirSync(flags.dir)
47
- for (let f of files) {
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
- .catch(require('@oclif/core/handle'))
53
+ LS.run().then(() => {
54
+ require('@oclif/core/flush')
55
+ }, () => {
56
+ require('@oclif/core/handle')
57
+ })
55
58
  ```
56
59
 
57
- Then run either of these with:
60
+ Then run it like this:
58
61
 
59
62
  ```sh-session
60
- $ ./myscript
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/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._help();
45
+ new help_1.Help(cmd.config).showHelp(cmd.argv);
46
+ cmd.exit(0);
45
47
  },
46
48
  });
47
49
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "1.19.0",
4
+ "version": "1.19.1",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {