oclif is an open source framework for building a command line interface (CLI) in Node.js.
Questions tagged [oclif]
38 questions
9
votes
2 answers
Cannot find Typescript module even though tsc successfully manages to resolve it
I have a Node.js project written in Typescript which is expected to run as a CLI, and am having trouble to import a module located out of the node_modules directory using an absolute path (relative paths work fine). It might be important to mention…

edu_
- 850
- 2
- 8
- 16
8
votes
1 answer
Oclif prompt testing
I'm attempting to write a unit test for an Oclif hook that contains a simple prompt. I want to test the output of the hook, given a 'Y' or 'N' response to the prompt.
import {Hook} from '@oclif/config'
import cli from 'cli-ux'
const hook:…

jspru
- 1,060
- 1
- 9
- 17
4
votes
1 answer
Oclif dynamic autocomplete with http call
Does Oclif support making a call to an API and getting the values returned in order to be used for autocomplete? I have the following use case:
Multiple users are stored in a database
When the user presses show users , the CLI should…

anegru
- 1,023
- 2
- 13
- 29
3
votes
2 answers
oclif doesn't recognise created commands
I'm trying to build a CLI using oclif and it doesn't seem to work for anything I tried. I see a lot of people making it work for them so can maybe someone point me to my issue!
My steps:
1. mkdir test && cd test
2. npm init -f
3. npm i oclif
4.…

Constantin Suiu
- 214
- 2
- 12
3
votes
0 answers
How to use/build oclif (CLI node app) with nx?
I'm playing with a small app that fetch data from Jira, generates metrics and serves it to a React front-end (https://github.com/fgerthoffert/jira-agile-velocity).
It currently contains:
a CLI, built with oclif (https://oclif.io/docs/introduction)…

FrancoiG
- 101
- 1
2
votes
1 answer
How to import d3.js in a node and typescript project? [ERR_REQUIRE_ESM]
I'm working on a node project using typescript, oclif and d3.js, among other things. Typescript was configured by npx when creating the project with oclif so I didn't control all aspects of it (especially regarding TS, and I'm not an expert. TS is…

DrKabum
- 61
- 8
2
votes
2 answers
Using oclif in vscode, how to resolve "The inferred type of 'flags' cannot be named without a reference to..." problem?
I am building a CLI utility using oclif, writing it in Typescript.
Inside vscode all of the generated command files are giving me an error that says
The inferred type of 'flags' cannot be named without a reference to…

Fliggerty
- 73
- 7
2
votes
0 answers
Oclif - How to use compiled JS instead of TS
I have a CMD project based on oclif framework written on TypeScript. I'm wondering - is it possible to compile .ts into .js for production use?
I tried to compile files into ./lib folder, then run a command ./bin/run hello - Oclif still uses .ts…

Kirill Zhirnov
- 365
- 2
- 12
2
votes
2 answers
How do I create an OIDC login using oclif?
Can anyone please supply an example of using OCLIF to do an OIDC login from the command line. I think that the idea is that the login command should open a browser to login the page and spawn a server to capture authorization response. I am…

Ken
- 1,529
- 12
- 12
2
votes
0 answers
OClif mock method
Let's say I have
export class MyCommand {
async run() {
this.someCommand();
...
}
someCommand() {
}
}
I want to write a test for the run command but mock out the someCommand. How do you do that using the
test
.stdout()
…

Kousha
- 32,871
- 51
- 172
- 296
2
votes
0 answers
@oclif/test with `inquirer.prompt`
I am trying to test my entire cli dialogs using oclif and @oclif/test.
Prompts are made with inquirer.
Everything work fine, except the use of the .stdin( mock.
Feature extract looks like this:
...
const { sessionToken } = await inquirer.prompt([{
…

Slim
- 1,256
- 1
- 13
- 25
2
votes
1 answer
How test a user input using cli-ux prompt in oclif?
I am creating a cli app using oclif. The user executes a command, and the cli asks him if wants to continue (yes/no answer).
I trying to test the command that uses the cli-ux prompt. I want to simulate the user interaction to enter the 'yes'…

Rodrigo Suarez
- 184
- 6
1
vote
0 answers
How to add less/more command like pagination in a custom CLI?
I'm building a CLI with Node.js and want to add less/more like pagination.
I can just stdout the output and pipe it to less like this
but I'm not able to add the text highlight just like git log in the first picture.
I have searched about it but…

Anurag Bhagsain
- 363
- 3
- 10
1
vote
0 answers
Is it possible to validade oclif flags values
I want to know if it's possible to validate the flag value before the command is executed.
healthCheckPort: Flags.integer({
description: 'This flag allows you to choose what port the health check sever is running on.',
default: 6000,
…

n3n3
- 288
- 1
- 7
1
vote
0 answers
How can I create a single command cli with oclif?
I'm writing a CLI using oclif. I want to use it like mycli [flags]. But I could't found a method to create a silgle command CLI.
I have read oclif's docs, https://oclif.io/docs/flags; There's nothing about single how to create single command…

dennis gao
- 11
- 1