Skip to content

Commit

Permalink
Minor documentation update.
Browse files Browse the repository at this point in the history
  • Loading branch information
biot committed Nov 22, 2014
1 parent 3549364 commit 6b92b09
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Tokenline is a simple command-line shell, intended for systems with few
resources.
Tokenline is a simple command-line shell interface, intended for systems
with few resources.


FEATURES:
Expand Down Expand Up @@ -58,15 +58,15 @@ Only the token field is required; all others are optional:
be filled in here. The following are available:
T_ARG_INT integer
T_ARG_FLOAT floating-point value
T_ARG_FREQ frequency, as float followed by khz, mhz or ghz
T_ARG_FREQ frequency, as float followed by khz, mhz or ghz
T_ARG_STRING freeform string, should be quoted if it contains spaces
T_ARG_TOKEN one of a set of tokens in the subtokens field
T_ARG_HELP special type for the "help" command, see below
- subtokens
A t_token table contains a set of tokens to be used if this token is
used. For example, The T_SHOW token above might have a set of subtokens
selecting the thing to show (see example). When not used with T_ARG_TOKEN,
this table defines a new context
this table defines a new context.
- help
A freeform string which will be shown when help for this token is requested.

Expand Down Expand Up @@ -118,7 +118,8 @@ The above definitions are enough to make this work:
Show hardware information

This also gets you tab completion of all keywords, and lets you abbreviate
keywords. The following are equivalent:
keywords. The following are equivalent, and get your callback the same
tokens:

> show hardware
> sh hard
Expand All @@ -132,16 +133,17 @@ typedef void (*tl_printfunc)(void *user, const char *str);
void tl_init(t_tokenline *tl, t_token *tokens, t_token_dict *dict,
tl_printfunc printfunc, void *user)

Initializes a previously-allocated t_tokenline struct. This pointer
Initializes a previously-allocated t_tokenline struct "tl". This pointer
represents a single command-line instance, and will be passed to all
other API functions. "tokens" is the initial token tree for this instance,
and "tl_printfunc" is the function called when tokenline produces output.
"user" is a pointer which will be passed along to your printfunc.
and "printfunc" is the function called when tokenline produces output.
"user" is a pointer which will be passed along to all your callback
functions.

void tl_set_prompt(t_tokenline *tl, char *prompt)

Change the prompt tokenline uses. The pointer is used from then on,
so dynamic prompt changes can be done there as well.
so dynamic prompt changes can be done on that pointer.

typedef void (*tl_callback)(void *user, t_tokenline_parsed *p);
void tl_set_callback(t_tokenline *tl, tl_callback callback)
Expand All @@ -157,7 +159,7 @@ void tl_set_callback(t_tokenline *tl, tl_callback callback)
The list of entered tokens is in the tokens field, terminated by 0 (this
is why token integers must not be 0). An argument is represented by one
of the T_ARG_* types (see above), followed by an integer representing an
offset into the buf field where the value lives. This value is simply
offset into the "buf" field where the value lives. This value is simply
sizeof(int), sizeof(float) or a NULL-terminated string. For example,
the following command line:

Expand Down

0 comments on commit 6b92b09

Please sign in to comment.