Skip to content

Commit 69643ba

Browse files
committed
fix: yargs parser init
1 parent b926f38 commit 69643ba

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

index.ts

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,30 +16,24 @@
1616
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
1717
* PERFORMANCE OF THIS SOFTWARE.
1818
*/
19-
import * as yargs from 'yargs';
19+
import yargs from 'yargs'
20+
import { hideBin } from 'yargs/helpers'
21+
2022
import { VERSION, checkForUpdate } from './lib';
2123

2224
(async () => {
25+
const y = yargs(hideBin(process.argv));
26+
2327
await checkForUpdate();
2428

25-
const argv: any = await yargs
26-
.usage('IMQ Command Line Interface' +
29+
await y.usage('IMQ Command Line Interface' +
2730
`\nVersion: ${VERSION}` +
2831
'\n\nUsage: $0 <command>')
2932
.version(VERSION)
3033
.commandDir('src')
3134
.demandCommand()
32-
.wrap(yargs.terminalWidth())
35+
.wrap(y.terminalWidth())
3336
.help()
3437
.argv
3538
;
36-
37-
const commands = (yargs as any).getCommandInstance().getCommands();
38-
39-
if (commands.length && !(
40-
argv._[0] && ~commands.indexOf(argv._[0])
41-
)) {
42-
yargs.showHelp();
43-
process.exit(1);
44-
}
4539
})();

0 commit comments

Comments
 (0)