Giter Club home page Giter Club logo

Comments (2)

philnash avatar philnash commented on September 25, 2024

@dkundel I know you showed me where this is needed and the format you want it in, but that was a few weeks ago now. Can you point me to where this is used and what would be useful to export for your code, please?

from create-twilio-function.

dkundel avatar dkundel commented on September 25, 2024

Here is an example:

https://github.com/twilio-labs/twilio-run/blob/ts/src/commands/start.ts

Basically you need to export the following properties:

type Module {
  // Usage description
  describe: string;
  // list of ways to call the command
  command: string[];
  // defines the different flags and their types
  cliConfig: CliConfig; 
  // handler that receives the actual flags
  handler(argv: Flags): Promise<void>
}

Here's the definition of CliOptions: https://github.com/twilio-labs/twilio-run/blob/ts/src/commands/types.ts#L3

Here you can see how I'm consuming it compared to how I'm consuming yours:

https://github.com/twilio-labs/plugin-serverless/blob/master/src/commands/serverless/start.js

https://github.com/twilio-labs/plugin-serverless/blob/master/src/commands/serverless/init.js

Let me know if this helps. You can see in the respective commands folders in both directories how they map to each other.

I'm using yargs for the twilio-cli. I wrote a helper function that basically takes the flags that are defined in cliConfig.options and turns them into flags for oclif so that the two are automatically in sync. https://github.com/twilio-labs/plugin-serverless/blob/master/src/commands/serverless/start.js#L36-L38

from create-twilio-function.

Related Issues (20)

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.