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

Commit 343fc79

Browse files
committed
feat: annotations
1 parent b305f41 commit 343fc79

File tree

5 files changed

+25
-3
lines changed

5 files changed

+25
-3
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,14 @@ cli.action.stop('custom message') // shows 'starting a process... custom message
6868
This degrades gracefully when not connected to a TTY. It queues up any writes to stdout/stderr so they are displayed above the spinner.
6969

7070
![action demo](assets/action.gif)
71+
72+
# annotation
73+
74+
Shows an iterm annotation
75+
76+
```typescript
77+
// start the spinner
78+
cli.annotation('sometest', 'annotated with this text')
79+
```
80+
81+
![annotation demo](assets/annotation.png)

assets/annotation.png

90 KB
Loading

examples/annotation.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import ux from '../src'
2+
3+
ux.annotation('sometext', 'annotated with this text')

src/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,17 @@ export const cli = {
5656
} else {
5757
this.log(uri)
5858
}
59-
}
59+
},
60+
61+
annotation(text: string, annotation: string) {
62+
const supports = require('supports-hyperlinks')
63+
if (supports.stdout) {
64+
//\u001b]8;;https://google.com\u0007sometext\u001b]8;;\u0007
65+
this.log(`\u001b]1337;AddAnnotation=${text.length}|${annotation}\u0007${text}`)
66+
} else {
67+
this.log(text)
68+
}
69+
},
6070
}
6171
export default cli
6272

tsconfig.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
"forceConsistentCasingInFileNames": true,
55
"importHelpers": true,
66
"module": "commonjs",
7-
"noUnusedLocals": true,
8-
"noUnusedParameters": true,
97
"outDir": "./lib",
108
"pretty": true,
119
"rootDirs": [

0 commit comments

Comments
 (0)