Giter Site home page Giter Site logo

mon-jai / core Goto Github PK

View Code? Open in Web Editor NEW

This project forked from oclif/core

0.0 0.0 0.0 2.44 MB

Node.js Open CLI Framework. Built by Salesforce.

Home Page: https://oclif.io

License: MIT License

Shell 0.02% JavaScript 0.63% TypeScript 99.35%

core's Introduction

@oclif/core

base library for oclif CLIs

Version Downloads/week License

Migrating

See the v3 migration guide for an overview of breaking changes that occurred between v2 and v3.

See the v2 migration guide for an overview of breaking changes that occurred between v1 and v2.

Migrating from @oclif/config and @oclif/command? See the v1 migration guide.

CLI UX

The ux README contains detailed usage examples of using the ux export.

Usage

We strongly encourage you generate an oclif CLI using the oclif cli. The generator will generate an npm package with @oclif/core as a dependency.

You can, however, use @oclif/core in a standalone script like this:

#!/usr/bin/env -S node --loader ts-node/esm --no-warnings=ExperimentalWarning

import * as fs from 'fs'
import {Command, Flags, flush, handle} from '@oclif/core'

class LS extends Command {
  static description = 'List the files in a directory.'
  static flags = {
    version: Flags.version(),
    help: Flags.help(),
    dir: Flags.string({
      char: 'd',
      default: process.cwd(),
    }),
  }

  async run() {
    const {flags} = await this.parse(LS)
    const files = fs.readdirSync(flags.dir)
    for (const f of files) {
      this.log(f)
    }
  }
}

LS.run().then(
  async () => {
    await flush()
  },
  async (err) => {
    await handle(err)
  },
)

Then run it like this:

$ ts-node myscript.ts
...files in current dir...

core's People

Contributors

svc-cli-bot avatar mdonnalley avatar dependabot[bot] avatar rasphilco avatar mshanemc avatar peternhale avatar willieruemmele avatar rodesp avatar shetzel avatar amphro avatar cristiand391 avatar typhonrt avatar iowillhoit avatar dsokal avatar amcaplan avatar y-lakhdar avatar benatshippabo avatar liaoyinglong avatar yantze avatar oclif-bot avatar jayree avatar eob avatar rolyatmax avatar xlmnxp avatar rrthomas avatar rafaelmotaalves avatar nigelzor avatar f3l1x avatar michaelgoberling avatar gingermusketeer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.