-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
100 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,70 @@ | ||
import { helpers, termost } from "../src"; | ||
|
||
const program = termost("Example to showcase the `message` API"); | ||
type ProgramContext = { | ||
output: string; | ||
}; | ||
|
||
program.output({ | ||
handler() { | ||
const content = | ||
"A content formatted thanks to the `print` helper presets."; | ||
const program = termost<ProgramContext>( | ||
"Example to showcase the `message` API" | ||
); | ||
|
||
helpers.print(content); | ||
helpers.print(content, { type: "warning" }); | ||
helpers.print(content, { type: "error" }); | ||
helpers.print(content, { type: "success" }); | ||
helpers.print(content, { | ||
type: "information", | ||
label: "馃憢 You can also customize the label", | ||
}); | ||
helpers.print(["I support also", "multilines", "with array input"], { | ||
type: "information", | ||
label: "馃憢 You can also customize the label", | ||
}); | ||
console.log( | ||
helpers.format( | ||
"\nYou can also have a total control on the formatting through the `format` helper.", | ||
program | ||
.output({ | ||
handler() { | ||
const content = | ||
"A content formatted thanks to the `print` helper presets."; | ||
|
||
helpers.print(content); | ||
helpers.print(content, { type: "warning" }); | ||
helpers.print(content, { type: "error" }); | ||
helpers.print(content, { type: "success" }); | ||
helpers.print(content, { | ||
type: "information", | ||
label: "馃憢 You can also customize the label", | ||
}); | ||
helpers.print( | ||
["I support also", "multilines", "with array input"], | ||
{ | ||
color: "white", | ||
modifier: ["italic", "strikethrough", "bold"], | ||
type: "information", | ||
label: "馃憢 You can also customize the label", | ||
} | ||
) | ||
); | ||
}, | ||
}); | ||
); | ||
console.log( | ||
helpers.format( | ||
"\nYou can also have a total control on the formatting through the `format` helper.", | ||
{ | ||
color: "white", | ||
modifier: ["italic", "strikethrough", "bold"], | ||
} | ||
) | ||
); | ||
}, | ||
}) | ||
.output({ | ||
key: "output", | ||
handler() { | ||
return "Hello from previous output"; | ||
}, | ||
}) | ||
.output({ | ||
handler(context) { | ||
helpers.print( | ||
`A shareable value can also be displayed: ${context.output}` | ||
); | ||
}, | ||
}) | ||
.output({ | ||
async handler() { | ||
helpers.print( | ||
"I can also run asynchronous operations... Operation is starting..." | ||
); | ||
|
||
await wait(2000); | ||
|
||
helpers.print("Operation is finished"); | ||
}, | ||
}); | ||
|
||
const wait = (delay: number) => { | ||
return new Promise((resolve) => setTimeout(resolve, delay)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters