Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

oclif

Package Overview
Dependencies
Maintainers
2
Versions
507
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oclif - npm Package Compare versions

Comparing version 1.2.11 to 1.2.12

8

CHANGELOG.md

@@ -0,1 +1,9 @@

<a name="1.2.12"></a>
## [1.2.12](https://github.com/oclif/oclif/compare/f1829b73960bacd99efe1668a9e93bf23e578e62...v1.2.12) (2018-02-15)
### Bug Fixes
* fixed repo link ([dddd420](https://github.com/oclif/oclif/commit/dddd420))
<a name="1.2.11"></a>

@@ -2,0 +10,0 @@ ## [1.2.11](https://github.com/oclif/cli/compare/bbfac28675d71d64cfd8ab037856b7963555830c...v1.2.11) (2018-02-15)

8

package.json
{
"name": "oclif",
"description": "oclif: create your own CLI",
"version": "1.2.11",
"version": "1.2.12",
"author": "Jeff Dickey @jdxcode",
"bin": "./bin/run",
"bugs": "https://github.com/oclif/cli/issues",
"bugs": "https://github.com/oclif/oclif/issues",
"dependencies": {

@@ -56,3 +56,3 @@ "@oclif/command": "^1.2.25",

],
"homepage": "https://github.com/oclif/cli",
"homepage": "https://github.com/oclif/oclif",
"keywords": [

@@ -71,3 +71,3 @@ "oclif"

},
"repository": "oclif/cli",
"repository": "oclif/oclif",
"scripts": {

@@ -74,0 +74,0 @@ "build": "rm -rf lib && tsc",

@@ -30,2 +30,3 @@ oclif: Open CLI Framework

* [Other Command Options](#other-command-options)
* [Command Base Class](#command-base-class)
* [Topics](#topics)

@@ -268,3 +269,3 @@ * [Plugins](#plugins)

```js
// flags.ts
// src/flags.ts
import {flags} from '@oclif/command'

@@ -280,3 +281,3 @@ function getTeam() {

// commands/mycommand.ts
// src/commands/mycommand.ts
import {team} from '../flags'

@@ -313,2 +314,4 @@ import Command from '@oclif/command'

[See the base class to get an idea of what methods can be called on a command](https://github.com/oclif/command/blob/master/src/command.ts).
```js

@@ -341,5 +344,60 @@ import Command, {flags} from '@oclif/command'

static strict = false
async run() {
// show a warning
this.warn('uh oh!')
// exit with an error message
this.error('uh oh!!!')
// exit with status code
this.exit(1)
}
}
```
# Command Base Class
Use inheritance to share functionality between common commands:
```js
// src/base.ts
import Command, {flags} from '@oclif/command'
export default abstract class extends Command {
static flags = {
loglevel: flags.string({options: ['error', 'warn', 'info', 'debug']})
}
log(msg, level) {
switch (this.flags.loglevel) {
case 'error':
if (level === 'error') console.error(msg)
break
// a complete example would need to have all the levels
}
}
async init(err) {
// do some initialization
const {flags} = this.parse(this.constructor)
this.flags = flags
}
async catch(err) {
// handle any error from the command
}
async finally(err) {
// called after run and catch regardless of whether or not the command errored
}
}
// src/commands/mycommand.ts
import Command from '../base'
export class MyCommand extends Command {
async run() {
this.log('information', 'info')
this.log('uh oh!', 'error')
}
}
```
# Topics

@@ -396,3 +454,3 @@

_See code: [src/commands/command.ts](https://github.com/oclif/cli/blob/v1.2.10/src/commands/command.ts)_
_See code: [src/commands/command.ts](https://github.com/oclif/oclif/blob/v1.2.11/src/commands/command.ts)_

@@ -430,3 +488,3 @@ ## help [COMMAND]

_See code: [src/commands/multi.ts](https://github.com/oclif/cli/blob/v1.2.10/src/commands/multi.ts)_
_See code: [src/commands/multi.ts](https://github.com/oclif/oclif/blob/v1.2.11/src/commands/multi.ts)_

@@ -447,3 +505,3 @@ ## plugin [PATH]

_See code: [src/commands/plugin.ts](https://github.com/oclif/cli/blob/v1.2.10/src/commands/plugin.ts)_
_See code: [src/commands/plugin.ts](https://github.com/oclif/oclif/blob/v1.2.11/src/commands/plugin.ts)_

@@ -464,3 +522,3 @@ ## single [PATH]

_See code: [src/commands/single.ts](https://github.com/oclif/cli/blob/v1.2.10/src/commands/single.ts)_
_See code: [src/commands/single.ts](https://github.com/oclif/oclif/blob/v1.2.11/src/commands/single.ts)_
<!-- commandsstop -->
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc