0.59.11 โ€ข Published 2 months ago

@stacksjs/cli v0.59.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Stacks CLI

The simple way to build beautiful CLIs.

โ˜˜๏ธ Features

  • ๐ŸŽจ Easily create beautiful CLI apps
  • โšก๏ธ Lightweight, user-friendly, interactive prompts
  • ๐Ÿšฆ Elegant terminal spinners
  • โ›‘๏ธ Helper methods to run commands

๐Ÿค– Usage

bun install -d @stacksjs/cli

Now, you can use it in your project:

// command.ts
// you may create create a relatively complex CLI UI/UX via the following:
import { ExitCode, command, italic, prompts, spawn, spinner } from '@stacksjs/cli'

const stacks = command('stacks')

stacks
  .command('example', 'A dummy command') // bun buddy example
  .option('-i, --install', 'The install option', { default: true })
  .action(async (options) => {
    if (options.install)
      await install()

    const answer = await prompts.select({
      type: 'select',
      message: 'Are you trying to run this command?',
      choices: [
        { title: 'Run the command', value: 'run' },
        { title: 'Do not run the command', value: 'do-not-run' },
      ],
    })

    if (answer === 'run')
      install()
    else if (answer === 'do-not-run')
      log.info('Not running the command')
    else process.exit(ExitCode.InvalidArgument)
  })

async function install() {
  try {
    const spin = spinner('Running...').start()
    setTimeout(() => {
      spin.text = italic('This may take a few moments...')
    }, 5000)
    await spawn('bun install')
    spin.stop()
  }
  catch (error) {
    log.error(error)
  }
}

command.help() // automatically expose a -h and --help flag
command.version(version) // automatically expose a -v and --version flag
command.parse() // parse the command

You may now run the command via:

bun command.ts

To view a more detailed example, check out Buddy.

You may also use any of the following CLI utilities:

import {
  ansi256Bg,
  bgBlack,
  bgBlue,
  bgCyan,
  bgGray,
  bgGreen,
  bgLightBlue,
  bgLightCyan,
  bgLightGray,
  bgLightGreen,
  bgLightMagenta,
  bgLightRed,
  bgLightYellow,
  bgMagenta,
  bgRed,
  bgWhite,
  bgYellow,
  black,
  blue,
  bold,
  cyan,
  dim,
  gray,
  green,
  hidden,
  inverse,
  italic,
  lightBlue,
  lightCyan,
  lightGray,
  lightGreen,
  lightMagenta,
  lightRed,
  lightYellow,
  link,
  magenta,
  red,
  reset,
  strikethrough,
  underline,
  white,
  yellow
} from '@stacksjs/cli'

log.info(`hello ${bold(italic('world'))}`)

To view the full documentation, please visit https://stacksjs.org/cli.

๐Ÿงช Testing

bun test

๐Ÿ“ˆ Changelog

Please see our releases page for more information on what has changed recently.

๐Ÿšœ Contributing

Please review the Contributing Guide for details.

๐Ÿ Community

For help, discussion about best practices, or any other conversation that would benefit from being searchable:

Discussions on GitHub

For casual chit-chat with others using this package:

Join the Stacks Discord Server

๐Ÿ™๐Ÿผ Credits

Many thanks to the following core technologies & people who have contributed to this package:

๐Ÿ“„ License

The MIT License (MIT). Please see LICENSE for more information.

Made with ๐Ÿ’™

0.59.11

2 months ago

0.59.8

2 months ago

0.59.9

2 months ago

0.59.7

2 months ago

0.59.10

2 months ago

0.59.2

2 months ago

0.59.3

2 months ago

0.59.1

2 months ago

0.59.6

2 months ago

0.59.4

2 months ago

0.59.5

2 months ago

0.58.73

3 months ago

0.58.72

3 months ago

0.58.70

3 months ago

0.58.71

3 months ago

0.58.69

3 months ago

0.58.65

3 months ago

0.58.66

3 months ago

0.58.67

3 months ago

0.58.68

3 months ago

0.58.61

3 months ago

0.58.62

3 months ago

0.58.63

3 months ago

0.58.64

3 months ago

0.58.59

3 months ago

0.58.58

3 months ago

0.58.57

3 months ago

0.58.56

3 months ago

0.58.55

3 months ago

0.58.52

3 months ago

0.58.53

3 months ago

0.58.50

3 months ago

0.58.51

3 months ago

0.58.49

3 months ago

0.58.47

3 months ago

0.58.48

3 months ago

0.58.43

3 months ago

0.58.44

3 months ago

0.58.45

3 months ago

0.58.46

3 months ago

0.58.27

4 months ago

0.58.28

4 months ago

0.58.19

4 months ago

0.58.20

4 months ago

0.58.21

4 months ago

0.58.22

4 months ago

0.58.24

4 months ago

0.57.4

10 months ago

0.57.2

10 months ago

0.57.3

10 months ago

0.56.24

10 months ago

0.56.23

10 months ago

0.56.28

10 months ago

0.56.27

10 months ago

0.56.29

10 months ago

0.56.35

10 months ago

0.56.34

10 months ago

0.56.31

10 months ago

0.56.30

10 months ago

0.56.33

10 months ago

0.56.32

10 months ago

0.56.3

11 months ago

0.52.10

12 months ago

0.53.1

12 months ago

0.52.9

12 months ago

0.52.7

12 months ago

0.52.8

12 months ago

0.52.5

12 months ago

0.52.6

12 months ago

0.52.3

12 months ago

0.52.4

12 months ago

0.52.1

12 months ago

0.52.2

12 months ago

0.52.0

12 months ago

0.51.0

1 year ago

0.50.0

1 year ago

0.44.10

1 year ago

0.49.1

1 year ago

0.48.2

1 year ago

0.46.4

1 year ago

0.44.11

1 year ago

0.44.6

1 year ago

0.49.2

1 year ago

0.48.3

1 year ago

0.47.4

1 year ago

0.44.12

1 year ago

0.44.7

1 year ago

0.47.1

1 year ago

0.46.2

1 year ago

0.49.0

1 year ago

0.48.1

1 year ago

0.47.2

1 year ago

0.46.3

1 year ago

0.46.0

1 year ago

0.45.1

1 year ago

0.47.0

1 year ago

0.46.1

1 year ago

0.45.2

1 year ago

0.45.0

1 year ago

0.49.3

1 year ago

0.44.8

1 year ago

0.44.9

1 year ago

0.43.1

1 year ago

0.43.0

1 year ago

0.42.2

1 year ago

0.42.1

1 year ago

0.41.1

1 year ago

0.41.0

1 year ago

0.40.0

1 year ago

0.39.1

1 year ago

0.39.0

1 year ago

0.38.4

1 year ago

0.38.3

1 year ago

0.38.2

1 year ago

0.38.1

1 year ago