Skip to content

File wsh_shell_option.h

FileList > src > wsh_shell_option.h

Go to the source code of this file

Definition of shell command-line option object and creation macros. More...

  • #include "wsh_shell_types.h"

Classes

Type Name
struct WshShellOption_Ctx_t
Option usage context during parsing.
struct WshShellOption_t
Represents a shell command-line option.

Public Types

Type Name
enum WSH_SHELL_OPTION_TYPE_t
Enumeration of all option types used by the shell.

Public Static Attributes

Type Name
const WshShell_Char_t * WshShell_OptionTypeNames = /* multi line expression */
Human-readable names of option types.

Public Static Functions

Type Name
const WshShell_Char_t * WshShell_OptTypeStr_Get (WSH_SHELL_OPTION_TYPE_t optType)
Return the string name of an option type.

Macros

Type Name
define WSH_SHELL_OPTION_TYPES_TABLE () /* multi line expression */
Internal macro: full list of option types.
define WSH_SHELL_OPT_ACCESS_ADMIN 0x08
define WSH_SHELL_OPT_ACCESS_ANY (WSH\_SHELL\_OPT\_ACCESS\_READ \| WSH\_SHELL\_OPT\_ACCESS\_WRITE \| WSH\_SHELL\_OPT\_ACCESS\_EXECUTE)
define WSH_SHELL_OPT_ACCESS_EXECUTE 0x04
define WSH_SHELL_OPT_ACCESS_NO 0x00
define WSH_SHELL_OPT_ACCESS_READ 0x01
define WSH_SHELL_OPT_ACCESS_WRITE 0x02
define WSH_SHELL_OPT_DESCR (descr) ""
define WSH_SHELL_OPT_END () WSH\_SHELL\_OPTION\_END, WSH\_SHELL\_OPT\_ACCESS\_ANY, 0, NULL, NULL, NULL
Marks the end of an option array.
define WSH_SHELL_OPT_FLOAT (acc, short, long, descr) WSH\_SHELL\_OPTION\_FLOAT, (acc), 1, (short), (long), WSH\_SHELL\_OPT\_DESCR(descr)
Define a float argument option.
define WSH_SHELL_OPT_HELP () /* multi line expression */
Define a built-in help option (e.g. "--help" or"-h" ).
define WSH_SHELL_OPT_INT (acc, short, long, descr) WSH\_SHELL\_OPTION\_INT, (acc), 1, (short), (long), WSH\_SHELL\_OPT\_DESCR(descr)
Define an integer argument option.
define WSH_SHELL_OPT_INTERACT (acc) /* multi line expression */
Define an option for entering interactive mode.
define WSH_SHELL_OPT_MULTI_ARG (acc, argnum, short, long, descr) WSH\_SHELL\_OPTION\_MULTI\_ARG, (acc), (argnum), (short), (long), WSH\_SHELL\_OPT\_DESCR(descr)
Define an option that accepts multiple arguments.
define WSH_SHELL_OPT_NO (acc, descr) WSH\_SHELL\_OPTION\_NO, (acc), 0, "--", "---", WSH\_SHELL\_OPT\_DESCR(descr)
Define a special option that matches the command name only (no flags).
define WSH_SHELL_OPT_STR (acc, short, long, descr) WSH\_SHELL\_OPTION\_STR, (acc), 1, (short), (long), WSH\_SHELL\_OPT\_DESCR(descr)
Define a string argument option.
define WSH_SHELL_OPT_WAITS_INPUT (acc) WSH\_SHELL\_OPTION\_WAITS\_INPUT, (acc), 0, NULL, NULL, NULL
Define an option that triggers when input is provided with no flags.
define WSH_SHELL_OPT_WO_PARAM (acc, short, long, descr) WSH\_SHELL\_OPTION\_WO\_PARAM, (acc), 0, (short), (long), WSH\_SHELL\_OPT\_DESCR(descr)
Define an option that requires no arguments.
define X_ENTRY (id, str) id,
define X_ENTRY (id, str) id,

Detailed Description

This file provides structures and macros for defining and managing command-line options in the WSH shell framework.

Author:

Whoosh Embedded Team

Copyright:

Copyright (c) 2024

Public Types Documentation

enum WSH_SHELL_OPTION_TYPE_t

Enumeration of all option types used by the shell.

1
2
3
enum WSH_SHELL_OPTION_TYPE_t {
    WSH_SHELL_OPTION_TYPES_TABLE =() WSH_SHELL_OPTION_ENUM_SIZE
};


Public Static Attributes Documentation

variable WshShell_OptionTypeNames

Human-readable names of option types.

const WshShell_Char_t* WshShell_OptionTypeNames[];


Public Static Functions Documentation

function WshShell_OptTypeStr_Get

Return the string name of an option type.

1
2
3
static inline const WshShell_Char_t * WshShell_OptTypeStr_Get (
    WSH_SHELL_OPTION_TYPE_t optType
) 

Parameters:

  • optType The option type.

Returns:

Option type name as string.


Macro Definition Documentation

define WSH_SHELL_OPTION_TYPES_TABLE

Internal macro: full list of option types.

1
2
3
#define WSH_SHELL_OPTION_TYPES_TABLE (

) `/* multi line expression */`


define WSH_SHELL_OPT_ACCESS_ADMIN

#define WSH_SHELL_OPT_ACCESS_ADMIN `0x08`

define WSH_SHELL_OPT_ACCESS_ANY

#define WSH_SHELL_OPT_ACCESS_ANY `(WSH_SHELL_OPT_ACCESS_READ | WSH_SHELL_OPT_ACCESS_WRITE | WSH_SHELL_OPT_ACCESS_EXECUTE)`

define WSH_SHELL_OPT_ACCESS_EXECUTE

#define WSH_SHELL_OPT_ACCESS_EXECUTE `0x04`

define WSH_SHELL_OPT_ACCESS_NO

#define WSH_SHELL_OPT_ACCESS_NO `0x00`

define WSH_SHELL_OPT_ACCESS_READ

#define WSH_SHELL_OPT_ACCESS_READ `0x01`

define WSH_SHELL_OPT_ACCESS_WRITE

#define WSH_SHELL_OPT_ACCESS_WRITE `0x02`

define WSH_SHELL_OPT_DESCR

1
2
3
#define WSH_SHELL_OPT_DESCR (
    descr
) `""`

define WSH_SHELL_OPT_END

Marks the end of an option array.

1
2
3
#define WSH_SHELL_OPT_END (

) `WSH_SHELL_OPTION_END, WSH_SHELL_OPT_ACCESS_ANY, 0, NULL, NULL, NULL`


define WSH_SHELL_OPT_FLOAT

Define a float argument option.

1
2
3
4
5
6
#define WSH_SHELL_OPT_FLOAT (
    acc,
    short,
    long,
    descr
) `WSH_SHELL_OPTION_FLOAT, (acc), 1, (short), (long), WSH_SHELL_OPT_DESCR(descr)`

Parameters:

  • acc Access rights mask.
  • short Short flag.
  • long Long flag.
  • descr Help description.

define WSH_SHELL_OPT_HELP

Define a built-in help option (e.g. "--help" or"-h" ).

1
2
3
#define WSH_SHELL_OPT_HELP (

) `/* multi line expression */`


define WSH_SHELL_OPT_INT

Define an integer argument option.

1
2
3
4
5
6
#define WSH_SHELL_OPT_INT (
    acc,
    short,
    long,
    descr
) `WSH_SHELL_OPTION_INT, (acc), 1, (short), (long), WSH_SHELL_OPT_DESCR(descr)`

Parameters:

  • acc Access rights mask.
  • short Short flag.
  • long Long flag.
  • descr Help description.

define WSH_SHELL_OPT_INTERACT

Define an option for entering interactive mode.

1
2
3
#define WSH_SHELL_OPT_INTERACT (
    acc
) `/* multi line expression */`


define WSH_SHELL_OPT_MULTI_ARG

Define an option that accepts multiple arguments.

1
2
3
4
5
6
7
#define WSH_SHELL_OPT_MULTI_ARG (
    acc,
    argnum,
    short,
    long,
    descr
) `WSH_SHELL_OPTION_MULTI_ARG, (acc), (argnum), (short), (long), WSH_SHELL_OPT_DESCR(descr)`

Parameters:

  • acc Access rights mask.
  • argnum Number of arguments.
  • short Short flag.
  • long Long flag.
  • descr Help description.

define WSH_SHELL_OPT_NO

Define a special option that matches the command name only (no flags).

1
2
3
4
#define WSH_SHELL_OPT_NO (
    acc,
    descr
) `WSH_SHELL_OPTION_NO, (acc), 0, "--", "---", WSH_SHELL_OPT_DESCR(descr)`

Parameters:

  • acc Access rights mask.

define WSH_SHELL_OPT_STR

Define a string argument option.

1
2
3
4
5
6
#define WSH_SHELL_OPT_STR (
    acc,
    short,
    long,
    descr
) `WSH_SHELL_OPTION_STR, (acc), 1, (short), (long), WSH_SHELL_OPT_DESCR(descr)`

Parameters:

  • acc Access rights mask.
  • short Short flag.
  • long Long flag.
  • descr Help description.

define WSH_SHELL_OPT_WAITS_INPUT

Define an option that triggers when input is provided with no flags.

1
2
3
#define WSH_SHELL_OPT_WAITS_INPUT (
    acc
) `WSH_SHELL_OPTION_WAITS_INPUT, (acc), 0, NULL, NULL, NULL`

Parameters:

  • acc Access rights mask.

define WSH_SHELL_OPT_WO_PARAM

Define an option that requires no arguments.

1
2
3
4
5
6
#define WSH_SHELL_OPT_WO_PARAM (
    acc,
    short,
    long,
    descr
) `WSH_SHELL_OPTION_WO_PARAM, (acc), 0, (short), (long), WSH_SHELL_OPT_DESCR(descr)`

Parameters:

  • acc Access rights mask.
  • short Short flag (e.g. "-a").
  • long Long flag (e.g. "--all").
  • descr Help description.

define X_ENTRY

1
2
3
4
#define X_ENTRY (
    id,
    str
) `id,`

define X_ENTRY

1
2
3
4
#define X_ENTRY (
    id,
    str
) `id,`


The documentation for this class was generated from the following file src/wsh_shell_option.h