Skip to content

Commit

Permalink
Init oclif cli
Browse files Browse the repository at this point in the history
  • Loading branch information
andylouisqin committed Dec 20, 2024
1 parent a8ded5b commit 26c0424
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 100 deletions.
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,5 @@
/tmp
/node_modules
oclif.manifest.json



yarn.lock
pnpm-lock.yaml

41 changes: 1 addition & 40 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 2 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
"dependencies": {
"@oclif/core": "^4",
"@oclif/plugin-help": "^6",
"@oclif/plugin-plugins": "^5",
"prism-react-renderer": "^2.4.1"
"@oclif/plugin-plugins": "^5"
},
"devDependencies": {
"@oclif/prettier-config": "^0.2.1",
Expand Down Expand Up @@ -52,13 +51,7 @@
"plugins": [
"@oclif/plugin-help",
"@oclif/plugin-plugins"
],
"topicSeparator": " ",
"topics": {
"hello": {
"description": "Say hello to the world and others"
}
}
]
},
"repository": "opentoolsteam/cli",
"scripts": {
Expand Down
25 changes: 0 additions & 25 deletions src/commands/hello/index.ts

This file was deleted.

19 changes: 0 additions & 19 deletions src/commands/hello/world.ts

This file was deleted.

33 changes: 33 additions & 0 deletions src/commands/install.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import {Args, Command, Flags} from '@oclif/core'

export default class Install extends Command {
static args = {
package_name: Args.string({
description: 'package to install',
required: true,
}),
}

static description = 'Install a package'

static examples = [
'<%= config.bin %> <%= command.id %> package-name',
]

static flags = {
force: Flags.boolean({char: 'f'}),
name: Flags.string({char: 'n', description: 'name to print'}),
}

static aliases = ['i']

public async run(): Promise<void> {
const {args, flags} = await this.parse(Install)

const name = flags.name ?? 'world'
this.log(`hello ${name} from /Users/qin/Projects/cli/src/commands/install.ts!`)
if (args.package_name && flags.force) {
this.log(`you input --force and --package_name: ${args.package_name}`)
}
}
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export {run} from '@oclif/core'
console.log("Hi!");
14 changes: 14 additions & 0 deletions test/commands/install.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import {runCommand} from '@oclif/test'
import {expect} from 'chai'

describe('install', () => {
it('runs install cmd', async () => {
const {stdout} = await runCommand('install')
expect(stdout).to.contain('hello world')
})

it('runs install --name oclif', async () => {
const {stdout} = await runCommand('install --name oclif')
expect(stdout).to.contain('hello oclif')
})
})
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"compilerOptions": {
"composite": true,
"declaration": true,
"module": "Node16",
"outDir": "dist",
"rootDir": "src",
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"target": "es2022",
"moduleResolution": "node16"
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.tsbuildinfo

Large diffs are not rendered by default.

0 comments on commit 26c0424

Please sign in to comment.