Coder Social home page Coder Social logo

Automatic alias parsing about meow HOT 4 CLOSED

sindresorhus avatar sindresorhus commented on August 21, 2024 2
Automatic alias parsing

from meow.

Comments (4)

sindresorhus avatar sindresorhus commented on August 21, 2024

It's a cool idea. Not sure if it's a good fit here, though, as I'm trying to stay as unopinionated as possible. Gonna keep this open for a while to see if there's any interest in this.

In the meantime I made aliases (which uses parse-help), so you can easily plug it into meow.

const meow = require('meow');
const aliases = require('aliases');

const help = `
    Usage
      $ unicorn <name>

    Options
      -r, --rainbow  Lorem ipsum dolor sit amet
      -m, --magic    Aenean commodo ligula eget dolor
`;

meow(help, {
    alias: aliases(help, {h: 'help'})
})

You could potentially also make a more opinionated meow wrapper with this.

from meow.

SamVerschueren avatar SamVerschueren commented on August 21, 2024

I like the idea, but rather don't want to see it implemented in meow directly. The solution of @sindresorhus is quite nice!

In my opinion, the implementation of the cli app is decoupled from the documentation of the app. Today, I choose for the -r, --rainbow notation. But maybe tomorrow I like --rainbow (-r) better. So if I change the documentation, my cli app breaks because I haven't thought about adding the alias property because my documentation format is not supported.

With the solution of @sindresorhus I can write my own parser for --rainbow (-r). And if I want -r, --rainbow back, I can use the aliases module.

from meow.

corysimmons avatar corysimmons commented on August 21, 2024

@adjohnson916 I see what you're saying but I don't think the cli should impose aliases based on what our help text looks like.

from meow.

AndersDJohnson avatar AndersDJohnson commented on August 21, 2024

Thanks @sindresorhus for creating aliases based on my idea. Modular magic is to me an acceptable alternative to meow magic. Perhaps at some point we could include it in meow as an opt-in feature. If not, we should at least link to it from the README here.

from meow.

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.