Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@cto.ai/cli-sdk
Advanced tools
A collection of common interactive command line user interfaces.
npm install @cto.ai/sdk
const { sdk, ux } from '@cto.ai/sdk';
const answers = await ux.prompt(questions);
Question A question object is a hash containing question related values:
A question object is a hash
containing question related values:
input
- Possible values: input
, number
, confirm
,
list
, rawlist
, expand
, checkbox
, password
, editor
, datetime
, autocomplete
, checkbox-plus
, fuzzy-path
, emoji
name
(followed by a colon).strings
, or objects
containing a name
(to display in list), a value
(to save in the answers hash), and a short
(to display after selection) properties. The choices array can also contain a Separator
.true
if the value is valid, and an error message (String
) otherwise. If false
is returned, a default error message is provided.true
or false
depending on whether or not this question should be asked. The value can also be a simple boolean.list
, rawList
, expand
or checkbox
.message
after question is answered.for more information: https://github.com/SBoudrias/Inquirer.js#documentation
Note:: allowed options written inside square brackets (
[]
) are optional. Others are required.
{type: 'list'}
Take type
, name
, message
, choices
[, default
, filter
] properties. (Note that
default must be the choice index
in the array or a choice value
)
{type: 'rawlist'}
Take type
, name
, message
, choices
[, default
, filter
] properties. (Note that
default must be the choice index
in the array)
{type: 'expand'}
Take type
, name
, message
, choices
[, default
] properties. (Note that
default must be the choice index
in the array. If default
key not provided, then help
will be used as default choice)
Note that the choices
object will take an extra parameter called key
for the expand
prompt. This parameter must be a single (lowercased) character. The h
option is added by the prompt and shouldn't be defined by the user.
See examples/expand.js
for a running example.
{type: 'checkbox'}
Take type
, name
, message
, choices
[, filter
, validate
, default
] properties. default
is expected to be an Array of the checked choices value.
Choices marked as {checked: true}
will be checked by default.
Choices marked as {mandatory: true}
will be checked and unselectable by default.
Choices with helpInfo
property provided will have toggable help info displayed. helpInfo
property takes in strings
.
Choices whose property disabled
is truthy will be unselectable. If disabled
is a string, then the string will be outputted next to the disabled choice, otherwise it'll default to "Disabled"
. The disabled
property can also be a synchronous function receiving the current answers as argument and returning a boolean or a string.
{type: 'confirm'}
Take type
, name
, message
, [default
] properties. default
is expected to be a boolean if used.
{type: 'input'}
Take type
, name
, message
[, default
, filter
, validate
, transformer
] properties.
{type: 'number'}
Take type
, name
, message
[, default
, filter
, validate
, transformer
] properties.
{type: 'password'}
Take type
, name
, message
, mask
,[, default
, filter
, validate
] properties.
Note that mask
is required to hide the actual user input.
{type: 'editor'}
Take type
, name
, message
[, default
, filter
, validate
] properties
Launches an instance of the users preferred editor on a temporary file. Once the user exits their editor, the contents of the temporary file are read in as the result. The editor to use is determined by reading the $VISUAL or $EDITOR environment variables. If neither of those are present, notepad (on Windows) or vim (Linux or Mac) is used.
{type: 'checkbox-plus'}
Takes type
, name
, message
, source
or autocomplete
[, filter
, validate
, default
, pageSize
, highlight
, searchable
, enablebackspace
, answer
, footer
, header
, keypress
, searching
, noresult
] properties.
for example and more information: https://github.com/yviscool/inquirer-checkbox-plus
{type: 'fuzzypath'}
Take type
, name
, message
[, excludePath
, itemType
, rootPath
, suggestOnly
]
for example and more information: https://github.com/adelsz/inquirer-fuzzy-path
{type: 'emoji'}
Take type
, name
, message
for example and more information: https://github.com/tannerntannern/inquirer-emoji
ux.colors.green('Green text');
ux.colors.red('Red text');
for more information: https://github.com/chalk/chalk#usage
Prints a string message for the user.
await ux.print("Hello world!");
await ux.print(`Found ${records.length} records`);
// start the spinner
ux.spinner.start('starting a process');
// show on stdout instead of stderr
ux.spinner.start('starting a process', { stdout: true });
// stop the spinner
ux.spinner.stop(); // shows 'starting a process... done'
ux.spinner.stop('custom message'); // shows 'starting a process... custom message'
Waits for 1 second or given milliseconds
await cli.wait();
await cli.wait(3000);
Create a hyperlink (if supported in the terminal)
await ux.url('sometext', 'https://google.com');
// shows sometext as a hyperlink in supported terminals
// shows https://google.com in unsupported terminals
cli.annotation('sometest', 'annotated with this text');
ux.table(data, columns, options);
for more information: https://github.com/oclif/cli-ux#clitable
Generate a tree and display it
let tree = cli.tree();
tree.insert('foo');
tree.insert('bar');
let subtree = cli.tree();
subtree.insert('qux');
tree.nodes.bar.insert('baz', subtree);
tree.display();
Outputs:
├─ foo
└─ bar
└─ baz
└─ qux
Send a track event to cto.ai api
sdk.track(tags, metadata)
FAQs
A collection of common interactive command line user interfaces.
The npm package @cto.ai/cli-sdk receives a total of 2 weekly downloads. As such, @cto.ai/cli-sdk popularity was classified as not popular.
We found that @cto.ai/cli-sdk demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.