Giter Club home page Giter Club logo

Comments (4)

c-bata avatar c-bata commented on May 23, 2024

You can persist histories between sessions via OptionHistory. When executor is called, you save a command in something log file you created. And when starting your program, please open a log file, extract executed commands and pass it to OptionHistory.

from go-prompt.

sandipb avatar sandipb commented on May 23, 2024

Yeah, I was thinking of doing that in the mean time. I was merely making an enhancement request for something more automated. :)

e.g.

func OptionLoadHistory(in io.Reader){
}

func OptionSaveHistory(out io.Writer) {
}

Then prompt.Run() can load lines into history from in at the beginning and write current history to out before returning.

from go-prompt.

rohityadavcloud avatar rohityadavcloud commented on May 23, 2024

@c-bata please advise, thanks.

from go-prompt.

cmprmsd avatar cmprmsd commented on May 23, 2024

I know this issue is quite old but stumbled across the same thing. I can set OptionHistory in order to load history strings as array but there is no way to change the behavior during a shell instantiation.

E.g.

prompt.OptionHistory([]string{"a", "b"})

I'd also expect there is a deferred function which will execute when the application exits or after each command. So a OptionSaveHistory function which takes the last command as string would be great.

That way you could implement the storage of the command history yourself (independent from a file system). Saving to databases would be no problem that way.

In my case I use cobra-shell, which allows passing Options but is static in itself. So I would not want to change cobra-shell but rather use the Option flags.

from go-prompt.

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.