Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
feat: annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed May 9, 2018
1 parent b305f41 commit 343fc79
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,14 @@ cli.action.stop('custom message') // shows 'starting a process... custom message
This degrades gracefully when not connected to a TTY. It queues up any writes to stdout/stderr so they are displayed above the spinner.

![action demo](assets/action.gif)

# annotation

Shows an iterm annotation

```typescript
// start the spinner
cli.annotation('sometest', 'annotated with this text')
```

![annotation demo](assets/annotation.png)
Binary file added assets/annotation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions examples/annotation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import ux from '../src'

ux.annotation('sometext', 'annotated with this text')
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,17 @@ export const cli = {
} else {
this.log(uri)
}
}
},

annotation(text: string, annotation: string) {
const supports = require('supports-hyperlinks')
if (supports.stdout) {
//\u001b]8;;https://google.com\u0007sometext\u001b]8;;\u0007
this.log(`\u001b]1337;AddAnnotation=${text.length}|${annotation}\u0007${text}`)
} else {
this.log(text)
}
},
}
export default cli

Expand Down
2 changes: 0 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
"forceConsistentCasingInFileNames": true,
"importHelpers": true,
"module": "commonjs",
"noUnusedLocals": true,
"noUnusedParameters": true,
"outDir": "./lib",
"pretty": true,
"rootDirs": [
Expand Down

0 comments on commit 343fc79

Please sign in to comment.