Giter VIP home page Giter VIP logo

embedded-cli's People

Contributors

1saeed avatar ccrome avatar funbiscuit avatar icamaster avatar ldmi3i avatar mtgstuber avatar neusaap avatar olmanqj avatar seanalling-dojofive avatar ymkim92 avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

embedded-cli's Issues

Add onEmpty command binding

Currently on any user input something is called - either registered binding or general onCommand when given command is not registered. The only exception is if input empty (user pressed "enter" multiple times). In this case nothing is called.
Add extra optional command binding - onEmpty which will be called when entered command is empty (or contains only whitespace).

Initial request by @Jeff-RavenLabs in #18

Make single header build optional in CMakeLists

In CMakeLists for library single-header build should be optional (since it requires python) and disabled by default.
It should be configurable via BUILD_SINGLE_HEADER option e.g. cmake -DBUILD_SINGLE_HEADER=On

Add access to raw input inside command binding

Example:

void onAdc(EmbeddedCli *cli, char *args, void *context) {
    // somehow get input
   while (embeddedCliBytesAvailable(cli) > 0) {
       uint8_t b = embeddedCliReadByte(cli);
   }
}

If you input is read from cli, it will not be then processed as command. For example suppose command binding for get-adc and following input is given:

get-adc
get-adc
get-adc

If in binding get-adc 3 bytes are read, then cli will see following:

get-adc // call binding get-adc
-adc // call unknown command "-adc" ("get" was read by user inside binding)
get-adc // call binding get-adc

Another important thing is that this will work correctly only if raw input is provided to cli only inside ISR. Otherwise new input will not be added while command binding is executing (unless it is added it manually, but that's a bad design)

Initial request by @windsunsjtu in #15

additional features

It would be nice if the equals sign, or other operators could be identified as tokens, the problem would be that there might be no space character, 1+2 would be one token compared to 1 + 2, which would be 3 tokens.
If you did this, too, the argument list could not be edited on top of itself during the tokenizing process because the tokens would end up longer than the input string, destroying the input string before tokenizing completes.

Just an idea, I'm going down this path using your code as a starting point.
Please let me know what you think,

Compiler warning when compiled with -Wall

I pulled your code into a project I'm writing now and it works great, thanks for providing this, it was exactly what I was looking for.

Compiling the code with a old gcc 5.4.0 cross compiler with the -Wall flag gives one warning:

embedded-cli/lib/src/embedded_cli.c:7:20: warning: unused variable 'impl' [-Wunused-variable]
EmbeddedCliImpl* impl = (EmbeddedCliImpl*)t->_impl;
^
embedded-cli/lib/src/embedded_cli.c:803:5: note: in expansion of macro 'PREPARE_IMPL'
PREPARE_IMPL(cli)
^

It looks like the PREPARE_IMPL macro does not need to be called in the initInternalBindings() routine.

Thanks!

Argument parsing

Hi.

Your library is very cool. I'm using it in my hobby project in ESP-IDF. Can you solve somehow the quoted arguments?

mycmd "this is my arg" 123
//---
//command is mycmd, first arg is "this is my arg" and other is 123.

This would be nice.

Invalid CMake settings for compiling as a library and using C

Describe the bug

Using a CMake project configured for C source code only, CMAKE_CXX_COMPILER_ID is undefined resulting in
a warning being printed to terminal, "Can't enable extra flags for compiler ".

Compiler used for project is arm-none-eabi-gcc

To Reproduce

Assuming embedded-cli is a git submodule, from root CMakeLists.txt, include add_subdirectory(embedded-cli) line to build embedded-cli as a library.

Generate CMake environment. During generation, CMake will print warning "Can't enable extra flags for compiler ".

Expected behavior

No warning should be printed, and embedded-cli flags should be added to GNU compiler.

Resolution

Embedded-cli is configured as a C project

project(embedded_cli C)

The above does not include CXX, as such, CMAKE_CXX_COMPILER_ID will never be populated.

Two methods can be used to resolve bug:

  1. Add CXX to project
    project(embedded_cli C CXX)
    
  2. Change CMAKE_CXX_COMPILER_ID to CMAKE_C_COMPILER_ID

Option 2 should be preffered as embedded-cli uses C source files and not C++.

Test both versions of library

Currently only normal distribution (.h+.c files) is tested in CI. Single header build is not tested.
In tests we should test single header version (if it was build) or nomal version (if single header not configured). Single header version will be configurable via BUILD_SINGLE_HEADER in #26
In CI both versions must be tested.

Make Auto Completion Optional

Hi,
could you please make auto completion optional by a flag e.g. in the NewEmbeddedCLI construction and/or an activation/deactivation function?
This would help to be able to use the interface for human operators at the start and switch to e.g. scripted commands from a computer alter.

Cheers
Philipp

Building library on Windows generates error

Describe the bug

When building CMake on Windows, the following is output to console:

  Target "embedded_cli_win32" links to:

    EmbeddedCLI::SingleHeader

  but the target was not found.  Possible reasons include:

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.

To Reproduce

  1. Clone repository to a folder named embedded-cli
  2. cd embedded cli
  3. mkdir build
  4. cd build
  5. cmake -G "Ninja" ..

Expected behavior

Example programs should not be generated by default, example applications should only generate if user has explicitly asked to generate test application.

Add support for removal of bindings

Currently it is possible to add bindings at runtime without any issues. It will add more flexibility if there was an option to also remove bindings at runtime.

Length of buffer can cause overwritting config struct

CLI_UINT cliBuffer[BYTES_TO_CLI_UINTS(CLI_BUFFER_SIZE)];

I used sligthly edited code from example in nrf52840 build. I think I was able to spot potential bug.

Using: BYTES_TO_CLI_UINTS(CLI_BUFFER_SIZE) for static allocation of cliBuffer, and totalSize in embeddedCliNew for memset can cause overwritting config struct with zeros. It doesn't cause problems as long as buffer is allocated in memory after struct.

In case buffer is allocated before struct it can set zeros to entire config struct while calling embeddedCliNew due to starting address of cliBuffer being only BYTES_TO_CLI_UINTS(CLI_BUFFER_SIZE) bytes before config struct.

It happened on nrf52840. I could neither isolate any causing allocation issue compiler flags, nor replicate it in other systems.

Migrate to catch v3

Currently library uses old single-header version of catch2. Catch2 v3 is released, we should migrate to it.

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.