Code Monkey home page Code Monkey logo

Comments (7)

mindreframer avatar mindreframer commented on May 28, 2024 2

Yes, targeting different use cases with the same code base. I understand that this would be probably not that trivial - if we would add proper flag parsing and such... But we could start with the low hanging fruit: same command as in the interactive mode, just non-interactively executed. That alone would help a lot. All other bells & whistles might be non required. Just to keep the surface of this feature as small as possible.

If you think I could help somehow, just ask me. Would be glad to lend a hand on this :)

from ishell.

abiosoft avatar abiosoft commented on May 28, 2024 1

This is it https://godoc.org/github.com/abiosoft/ishell#Shell.Process.

e.g. shell.Process(os.Args[1:])

from ishell.

mindreframer avatar mindreframer commented on May 28, 2024 1

😻 @abiosoft It's awesome, thank you! This is exactly what I wanted! I will make a pull request with a Readme update later.

from ishell.

abiosoft avatar abiosoft commented on May 28, 2024

Thanks for your kind words :)

Can you explain a bit more about how that is expected to work and the usecases.

If I get you right, instead of getting into interactive mode, just execute the command and exit.

from ishell.

mindreframer avatar mindreframer commented on May 28, 2024

Hey, exactly this. The use case would be calling the binary in scripted environments without the possible complexities of real interactive environments. That would give you best of both worlds: interactive CLI with possibility for more traditional, non-interactive fallback with basically same results.

Some things might not work 100%, but still, that would be a really compelling reason to use ishell for everything CLI related in Go.

It should not be that hard, just getting the context, and executing the args in that env. Currently there is no public API for this...

We would have to figure out the best way to indicate the desired modus. Giving it an extra params at first position, that is then removed for all the commands, like:

$ /bin/some-cli scripted greet Someone Somehow

would understand, that is is non-interactive, call the greet command with modified args and after the execution exit the process. The exit code is up to a discussion. It could default to 0.

Do you think this could useful?

from ishell.

abiosoft avatar abiosoft commented on May 28, 2024

I think I get you now. Basically ishell without the interactiveness.

That sure can be done. I'm just thinking there are better libraries out there doing this already. e.g. spf13/cobra.

But I like the idea of toggling interactive and non-interactive mode with same code base.

from ishell.

abiosoft avatar abiosoft commented on May 28, 2024

I think it's safe to close this as the feature has been added.

Processing flags e.t.c are extra features and this thread can still be used for that discussion.

from ishell.

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.