Commit Graph

38 Commits

Author SHA1 Message Date
Neehar Vijay 78efd60297 client: fix non-interactive mode in some cases
Before this change, I noticed that some non-interactive commands
don't work,

  $ iwctl version

  $ iwctl help

while other ones do.

  $ iwctl station wlan0 show

This seems to be a typo bug in the if clause checking for additional
arguments.
2022-11-22 11:19:12 -06:00
James Prestwood 69e9945ef7 device: command: remove default device concept
There was quite a bit of framework behind setting/resetting a default
device, which is now no longer needed.
2022-08-11 15:47:20 -05:00
James Prestwood 9aefec6124 client: allow entity name to be passed to completion
There is a limitation of libreadline where no context/userdata
can be passed to completion functions. Thi affects iwctl since
the entity value isn't known to completion functions.

Workarounds such as getting the default device are employed but
its not a great solution.

Instead hack around this limitation by parsing the prompt to
extract the entity (second arg). Then use a generic match function
given to readline which can call the actual match function and
include the entity.
2022-08-11 15:47:02 -05:00
James Prestwood 82cc80e54e client: update command table header
The table header needs to be adjusted to include spaces between
columns.
2022-07-07 14:09:03 -05:00
Marcel Holtmann 89e476d992 client: Use include path from top source directory 2019-12-13 09:02:42 +01:00
James Prestwood e1ceafde3a client: fix use of non-ascii apostrophe 2019-11-21 14:00:35 -06:00
Tim Kourt 19529a4d3a client: Don't register agent without a need
Register agent iff no '--dontask' command-line option has been provided
or there are some other command line options besides '--dontask'
2019-09-19 12:36:12 -05:00
Tim Kourt 411834e089 client: Remove unused API 2019-09-19 12:36:12 -05:00
Tim Kourt 79ccff464f client: Provide '--help' command-line option
In addition, this improves the 'help' display
2019-09-19 11:29:09 -05:00
Tim Kourt 62d286a745 client: Add '--dontask' command-line option
This option prevents iwctl from prompting user for the secrets
if they were not provided as the command-line arguments.
2019-09-19 11:26:19 -05:00
Tim Kourt 0a1cd37228 client: Enable lookup of command options with no arguments.
Previously, command_option_get used to return NULL in the following
two scenarios: when command-line option with a such name didn’t exists
or its argument was not provided. This worked great for the cmd-line
options with the required arguments. With introduction of the cmd-line
options with no or optional arguments the function was changed to return
a boolean value indicating the existence of a such option and then, if
it had an argument - value_out variable would have been set.

Thereafter, this patch modifies the current usages of command_option_get.
Note, in these particular applications of command_option_get there is no
need to check the returned value from command_option_get, since these
options have the required arguments and we can only check if the value_out
parameter has been set or not.
2019-09-19 11:25:53 -05:00
Tim Kourt 8be98d6149 client: Change semantics of return value from command_init
Instead of returning the mode of execution, command_init now
returns whether we are done and need to exit.

Thereafter, the mode of execution is now obtain though the command
module’s API.
2019-09-17 16:17:30 -05:00
Tim Kourt 6d31c9313f client: Introduce command options
Enable parsing of the command-line options by the command module.
The parsed command-line option values are stored in command_options
list and made available through the module’s public API:
command_option_get – allows querying options by name,
command_has_options – checks existence of the options.
2019-08-15 15:06:59 -05:00
Tim Kourt f1dd6b1084 client: Fix network name completion after restart of iwd
Previously, on service disappeared event the list of the known
proxy objects was cleared, but pointers to the default entity
per command family wasn’t reset. Reset default entities for
the command families to remove the dead pointers to the deleted
proxy objects.

==1325== Invalid read of size 8
==1325==    at 0x4055D4: proxy_interface_is_same (dbus-proxy.c:439)
==1325==    by 0x407C28: match_by_partial_name (network.c:220)
==1325==    by 0x40547C: proxy_interface_find_all (dbus-proxy.c:424)
==1325==    by 0x405592: proxy_property_str_completion (dbus-proxy.c:153)
==1325==    by 0x407DA9: network_name_completion (network.c:241)
==1325==    by 0x4E596D5: rl_completion_matches (in /usr/lib64/libreadline.so.7.0)
2019-07-18 23:37:54 -05:00
Marcel Holtmann 42f5d905b1 client: List all enum values in switch statement 2018-12-07 08:58:53 +01:00
Tim Kourt 5afe4576a1 client: Enable 'help', 'version' cmds in non-interactive mode 2018-11-12 10:37:09 -06:00
Marcel Holtmann 63bafa7adf client: Fix includes for using with -std=c99 compiler option 2018-11-01 22:19:45 +01:00
Tim Kourt 1d931d8a68 client: add noninteractive support for cmds 2018-08-06 12:42:03 -05:00
Tim Kourt ef2878d5ee client: rename generic cmd list 2018-08-06 12:32:49 -05:00
Tim Kourt 2ba4efe39e client: add new command statuses
Split CMD_STATUS_OK into CMD_STATUS_DONE and CMD_STATUS_TRIGGERED.
The split is necessary for the enablement of noninteractive mode.
2018-08-06 12:32:22 -05:00
Andrew Zaborowski 15ade259e6 client: Fix parsing commands with no "entity" part
The code would assume that a command with argc >= 3 would always be
composed of <family name> <entity> <command> and thus
"known-networks forget <ssid>" could not be executed.  Instead of
checking argc >= 3 check whether command->entity is non-NULL.
2018-07-31 11:38:35 -05:00
Denis Kenzior 67e590cfeb client: Utilize l_parse_args 2018-07-30 08:59:55 -05:00
Tim Kourt c5cf3b083f client: add cmd line token finder
This allows to inspect the cmd line for the existence of a provided
token. This enables the completers to look back to what was entered
before them and make decisions based on that information. For
example, this can be used in completion of the property values
to identify the property for which the value is being completed.
2018-07-25 11:47:10 -05:00
Tim Kourt fd23c87110 client: define default entity setter for cmd families 2018-05-31 19:30:44 -05:00
Tim Kourt 2817aeb35d client: disable cmd completion for the agent prompt 2018-05-03 16:00:23 -05:00
Marcel Holtmann f41fa52f99 client: Set saveptr argument of strtok_r to NULL for initial invocation 2017-08-30 23:17:53 +02:00
Tim Kourt 9bb19526d9 client: Exclude unnecessary checks
Arrays are guaranteed to be initialized during
the compilation time.
2017-08-23 16:26:05 -05:00
Tim Kourt e6d4a34773 client: Add caption for misc. cmds 2017-05-30 17:14:08 -05:00
Tim Kourt bfbffa1111 client: Add 'forget' cmd for known network 2017-04-26 14:36:25 -05:00
Tim Kourt e0117febd5 client: Introduce cmd execution status 2017-04-26 14:36:25 -05:00
Tim Kourt 02b52adf61 client: Entity argument completion 2017-04-21 12:56:46 -05:00
Tim Kourt c85ea2f924 client: Command family argument completion 2017-04-21 12:56:46 -05:00
Tim Kourt 34797796ed client: Introduce command completion 2017-04-21 12:56:46 -05:00
Tim Kourt 6c2eae6999 client: Add COMMAND_FAMILY 2017-04-13 13:21:19 -05:00
Tim Kourt dcf2a0cae5 client: Implement command execution 2017-04-13 13:20:58 -05:00
Tim Kourt 17569c8d8b client: define basic command ops 2017-04-12 15:32:17 -05:00
Tim Kourt 4fc6a3038a client: Allow command registration 2017-04-11 16:48:15 -05:00
Tim Kourt db679448bc client: Introduce command files
The purpose of these files is to encapsulate all of
the command processing functionality
2017-04-11 16:48:15 -05:00