Giter Club home page Giter Club logo

cmdr's People

Contributors

mendelt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

cmdr's Issues

Allow library users to set hooks

Allow library users to set hooks to run code before/after a command has been run and before/after a command loop has finished.

This might be useful if a user wants to do audit logging for example.

Allow aliassing commands

As a client I should be able to create aliasses for commands.
One way to implement this is by adding an alias annotation to a command method where you can specify a list of alternative command names.

help property on the cmdr attribute

Just like the help property on the cmd attribute to let a user specify help text for commands there should be a help property on the cmdr attribute too that lets a user specify help text on a whole scope.

Create simple examples for each of the features

When each of the features is implement there should be examples showing how they work.

  • Running commands (already implemented)
  • Setting prompts
  • Override default function
  • Override empty function
  • Help text using help_ methods and annotations
  • Autocompletion
  • Pre/post command and pre/post commandloop hooks
  • Command implementation without the cmdr macro (already implemented)

Improve error handling

Show warnings or errors when the cmdr macro encounters unexpected input:

  • Warn when no do_methods are found. (can we generate warnings from a macro?)
  • Improve error message when macro is not on an impl block
  • Check method signatures for overridden and do_methods and show errors when they don't fit

Update the help function to allow showing custom help text for each command

The help or ? function should show custom help text for a command when called with a command name.

I see three ways this can be implemented;

  1. Like in Python Cmd where a do_command can have an associated help_command method that prints out the help tekst
  2. Another way might be to have the cmdr macro parse the doc-comments for functions and use these as help tekst. Although this seems a bit 'magic' and might interfere how a user of the cmdr library wants to write documentation.
  3. A third way is to annotate do_command with a help 'macro' that is picked up by the cmdr macro.

At the moment I lean towards implementing both option 1 and 3. Normally help_ methods will be used. Later an extra option can be implemented to easilly implement help_ methods with static text by using an annotiation.

Auto complete command parameters

Allow users of the library to implement auto completion of parameters for each command by implementing complete_ methods. These will receive a string of what the user typed so far and return a list of the possible ways to complete these

Be able to test the output of cmdr

I'm doing some unit testing to check if my software produces the correct results. Right now, cmdr uses println!() but it would be cool I could configure the output stream. Would that mean that scopes should store a reference to a "Write" interface and use write!() instead of print!()?
In addition to testing, I think it could also be needed if someone uses cmdr using some TCP stream or if they want to both stdout and log the commands and results produced.

(Feature) Provide a way to read from a file a series of instructions

It would be very useful to be able to read a series of instructions from a file. That would allow scripting as well as easy testing.
Should there be a way to configure to either 1) do all the instructions even if some returns errors 2) exit at the first instruction returning an error?
Also I'm not familiar with rust yet but there might be some additional design/testing involved in an async environment?

Update main documentation

Update the README.md to explain how the libary works, show a simple example and include links to all urls (crates.io, github, doc.rs) and badges (doc.rs??? and travis.ci)

Create a separate readme for crates.io

Allow a user to change the command in before_command hook

The before command hook should take ownership of the Line and return a Line so library-users can access and change parsed lines.
To do this in a way that does not burden the lib-user with the lifetime of the Line we need to get rid of these lifetimes. Probably by copying the parsed string in the Line instead of referencing slices.

Dynamic help text

Allow dynamic help instead of using doc strings or a help parameter on the cmd attribute as help text. This can be done by letting the library user specify a method to call that provides the help text and then calling it the moment help is retrieved.

Publish a new release?

Hi there, was just playing around with this crate and realized the version on crates.io is quite a bit older than what you have on master, seems the API has changed a bit as well.

If it's in a good state, mind publishing a new release?

Keep a command history.

Commands that have been typed earlier can be re-executed by using arrow keys to move up and down. Commands in the command history can then be edited and re-executed by pressing enter.

Persistent history across runs

i.e. create a ~/.<progname>_history that is used to bootstrap the history on startup. And commands are automatically logged to this history file

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.