Comments (3)
Hello! Any status on this?
from spinnies.
or use Spinnies.d.ts
based on @adamjarret #25
declare module "spinnies" {
type StopAllStatus = "succeed" | "fail" | "stopped";
type SpinnerStatus = StopAllStatus | "spinning" | "non-spinnable";
interface Spinner {
interval: number;
frames: string[];
}
interface SpinnerOptions {
text?: string;
indent?: number;
status?: SpinnerStatus;
color?: string;
succeedColor?: string;
failColor?: string;
}
interface Options {
color?: string;
succeedColor?: string;
failColor?: string;
spinnerColor?: string;
succeedPrefix?: string;
failPrefix?: string;
disableSpins?: boolean;
spinner?: Spinner;
}
export default class Spinnies {
static dots: Spinner;
static dashes: Spinner;
constructor(options?: Options);
add: (name: string, options?: SpinnerOptions) => SpinnerOptions;
pick: (name: string) => SpinnerOptions;
remove: (name: string) => SpinnerOptions;
update: (name: string, options?: SpinnerOptions) => SpinnerOptions;
succeed: (name: string, options?: SpinnerOptions) => SpinnerOptions;
fail: (name: string, options?: SpinnerOptions) => SpinnerOptions;
stopAll: (status?: StopAllStatus) => { [name: string]: SpinnerOptions };
hasActiveSpinners: () => boolean;
}
}
from spinnies.
I'm hoping to get types added to DefinitelyTyped over in DefinitelyTyped/DefinitelyTyped#59503. In the meantime, here is the slightly improved local type declarations file that I'm using in my project:
declare module "spinnies" {
const dots: Spinner;
const dashes: Spinner;
type Color =
"black"
| "red"
| "green"
| "yellow"
| "blue"
| "magenta"
| "cyan"
| "white"
| "gray"
| "redBright"
| "greenBright"
| "yellowBright"
| "blueBright"
| "magentaBright"
| "cyanBright"
| "whiteBright";
type StopAllStatus = "succeed" | "fail" | "stopped";
type SpinnerStatus = StopAllStatus | "spinning" | "non-spinnable";
interface Spinner {
interval: number;
frames: string[];
}
/**
* The configuration for a given spinner
*/
interface SpinnerOptions {
/**
* Text to show in the spinner. If none is provided, the name field will be shown.
*/
text: string;
/**
* Indent the spinner with the given number of spaces.
*/
indent: number;
/**
* Initial status of the spinner.
*/
status: SpinnerStatus;
/**
* The color of the text that accompanies the spinner. If not specified, the console's default foreground color is used.
*/
color?: Color;
/**
* The color for the text on success. Default value is `"green"`
*/
succeedColor: Color;
/**
* The color for the text on failure. Default value is `"red"`.
*/
failColor: Color;
/**
* The color of the spinner, when active. The default value is `"greenBright"`
*/
spinnerColor: Color;
}
/**
* Contains top-level configuration for the Spinnies class. Also allows the
* caller to override default values used in `SpinnerOptions`.
*/
interface Options {
/**
* The color of the text that accompanies the spinner. If not specified, the console's default foreground color is used.
*/
color?: Color;
/**
* The color for the text on success. Default value is `"green"`
*/
succeedColor: Color;
/**
* The color for the text on failure. Default value is `"red"`.
*/
failColor: Color;
/**
* The color of the spinner, when active. The default value is `"greenBright"`
*/
spinnerColor: Color;
/**
* The symbol to be used in place of the spinner on success. The default value is ✓.
*/
succeedPrefix: string;
/**
* The symbol to be used in place of the spinner on failure. The default value is ✖.
*/
failPrefix: string;
/**
* Disable spinner animations (will still print raw messages if `true`). The default value is `false`.
*/
disableSpins: boolean;
/**
* Defines the animated spinner to be used while each spinner is active/spinning.
*/
spinner: Spinner;
}
/**
* A class that manages multiple CLI spinners.
*/
export default class Spinnies {
/**
* The current configuration of this Spinnies object.
*/
options: Spinnies.Options;
constructor(options?: Partial<Spinnies.Options>);
/**
* Add a new spinner with the given name.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
add: (name: string, options?: Partial<Spinnies.SpinnerOptions>) => Spinnies.SpinnerOptions;
/**
* Get spinner by name.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
pick: (name: string) => Spinnies.SpinnerOptions;
/**
* Remove spinner with name.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
remove: (name: string) => Spinnies.SpinnerOptions;
/**
* Updates the spinner with name name with the provided options. Retains
* the value of options that aren't specified.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
update: (name: string, options?: Partial<Spinnies.SpinnerOptions>) => Spinnies.SpinnerOptions;
/**
* Sets the specified spinner status as succeed.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
succeed: (name: string, options?: Partial<Spinnies.SpinnerOptions>) => Spinnies.SpinnerOptions;
/**
* Sets the specified spinner status as fail.
*
* @returns full `SpinnerOptions` object for the given spinner, with
* defaults applied
*/
fail: (name: string, options?: Partial<Spinnies.SpinnerOptions>) => Spinnies.SpinnerOptions;
/**
* Stops the spinners and sets the non-succeeded and non-failed ones to the provided status.
*
* @returns an object that maps spinner names to final `SpinnerOptions` objects for each spinner, with
* defaults applied
*/
stopAll: (status?: Spinnies.StopAllStatus) => { [name: string]: Spinnies.SpinnerOptions };
/**
* @returns false if all spinners have succeeded, failed or have been stopped
*/
hasActiveSpinners: () => boolean;
/**
* Disables the spinner loop after all spinners have deactivated. Must be
* called after calling `remove` on the final spinner, otherwise the
* spinner loop will prevent the process from exiting.
*/
checkIfActiveSpinners: () => void;
}
}
from spinnies.
Related Issues (19)
- disable forcing dashes on win32 HOT 4
- A message text appears during `npm t` at zos
- Implement nested spinners
- Improve stream output on CI environments
- Indent
- Use kleur instead of chalk? HOT 2
- ability to spit out update status at desired location in terminal
- Spinner success message dublication on CI HOT 1
- Add typescript
- No spinner initialized with name: XX
- Ability to update success/failure prefixes
- Add the ability to send a promise as an option to spinnies
- Callback functions not being called on process signals HOT 1
- Bug: Process doesn't exit when `remove` is called on an active spinner HOT 2
- Add ability to remove a spinner from the spinners list HOT 4
- Allow custom non-spinnable prefix text HOT 1
- Add war and info to api
- text is leaking HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spinnies.