Giter VIP home page Giter VIP logo

cmd-l's Introduction

CMD-L

A command line handler for embedded devices.

This supports a variety of useful features, aimed at user friendly-ness, without an excessive overhead for an embedded devices.

image

Features

Argument parsing:

Arguments are described in data alongside your functions. This means arguments can be validated and parsed to the appropriate types before your funcition is called.

The following argument types are supported:

  • Numbers: 9600
    • Hex 0x2580
    • Engineering notation 9k6
  • Booleans 0 or 1
  • Strings 'Hey'
    • Python style escape sequences "\"Hey\"\r\x0A"
  • Byte arrays 6865790d0a or [68 65 79 0D 0A] (and more)

Tree menu structure:

Menus are built out of nodes, which may in turn be functions or more menus. This leads to a natural command tree.

─ root
  ├─ spi
  │   ├─ read(number)
  │   └─ write(bytes)
  ├─ uart
  │   ├─ read(number)
  │   └─ write(bytes)
  └─ version()

For example, a valid command may be uart write 'hello world'

PuTTY friendly design

While this could be used for machine interfaces - this module is targeted at human use. Entering commands should be forgiving, and rich in feedback. The menus can be explored without needing to know the exact syntax or arguments.

The following features support this.

  • Input Echo
  • Backspace
  • Colors for warnings and errors
  • Bell for errors & halts
  • Tab completion
  • A symbol ? to get information about a menu or function
  • Error messages to describe any parsing failures.

Usage

  • Add /Src/ to your build and include directories
  • Copy /Templates/CmdConf.h into your project, and modify to suit
  • #include "Cmd.h" in your files and get to work

Examples

An example based around STM32X on can be found here

cmd-l's People

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

wllis

cmd-l's Issues

Add support for negative numbers

This could be done with different data types Cmd_Arg_Uint vs Cmd_Arg_Int.
Alternately it could be a flag.
Or all integers could be signed - bounds checking will typically be required in the application anyway.

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.