summaryrefslogtreecommitdiffstats
path: root/common/complete.c
Commit message (Collapse)AuthorAgeFilesLines
* commands: drvinfo: support filtering by driverAhmad Fatoum2023-11-211-0/+15
| | | | | | | | | | | | | | | | | | | | | | | drvinfo can be very long especially for the in-tree defconfigs. Make it more convenient to use by add optional filtering support: barebox@board:/ drvinfo '*imx7d*' Driver Device(s) -------------------- imx7d-src 30390000.reset-controller@30390000.of imx7d_adc 30610000.adc@30610000.of 30620000.adc@30620000.of Use 'devinfo DEVICE' for more information Furthermore, tab completion for driver names is now supported as well. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231109122551.1486020-3-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* complete: add support for spaces in completionsAhmad Fatoum2023-11-211-18/+52
| | | | | | | | | | | | | | | | | | | Drivers have spaces inside their names, which makes tab completion tricky as it restarts for every separate argument. Support for doing this in readline and hush landed in commits 1498093ccd11 ("readline: Complete strings containing whitespaces correctly") and 70e0885229d2 ("hush: Fix handling '\ '") respectively. This only goes one way though, escape a completion suggestion. The suggestion needs to be unescaped again, so repeated <Tab> usage after modifying the prompt is understood. For this to work, skip backslashes in the argument being completed. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20231109122551.1486020-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: add support for device aliasesAhmad Fatoum2023-09-251-8/+6
| | | | | | | | | | | | | | | | | | | | Device names can get quite long, which makes them cumbersome to use on the shell, e.g. firmware:zynqmp-firmware:clock-controller.of. In addition, the names are prone to change when the device tree nodes are renamed. One way we work around this is using aliases, but that is partially at odds with upstream binding. This commit adds an alternative way of allowing drivers and board code to set an alias that affects only device_param_complete. This provides an easy way of defining device names that should be stable for use in shell scripts. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20230913132456.2211919-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: Print device nodes with %pOFSascha Hauer2023-07-031-1/+1
| | | | | | | We have the %pOF format specifier for printing device nodes. Use it where appropriate. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Rename struct device_d to deviceSascha Hauer2023-01-101-3/+3
| | | | | | | | | | | | | The '_d' suffix was originally introduced in case we want to import Linux struct device as a separate struct into barebox. Over time it became clear that this won't happen, instead barebox struct device_d is basically the same as Linux struct device. Rename the struct name accordingly to make porting Linux code easier. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Reviewed-by: Marco Felsch <m.felsch@pengutronix.de> Link: https://lore.barebox.org/20221214123512.189688-3-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: add new tutorial commandAhmad Fatoum2022-01-131-6/+15
| | | | | | | | | | | | We have a web demo at http://barebox.org/jsbarebox and it would be nice to have a tutorial there. Add a new tutorial command that cycles through a number of tips. Tutorial will follow later. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Link: https://lore.barebox.org/20220108171555.588426-2-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* complete: Use string_list_add_sort_uniq()Sascha Hauer2021-03-161-8/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* common: replace license statements with SPDX-License-IdentifiersAhmad Fatoum2020-11-271-10/+1
| | | | | | | | | | | | | For all files in common/ that already have a license text: - Replace with appropriate SPDX-License-Identifier - Remove empty comment lines around replacement - remove comment completely if only thing remaining is name of file without description Reviewed-by: Roland Hieber <rhi@pengutronix.de> Reviewed-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* commands: setenv: allow use with hush shellAhmad Fatoum2020-09-181-0/+6
| | | | | | | | | | | | | | | | | | | setenv was so far restricted to the simple shell, because with hush, users could just do dev.var=VAL for setting variables in the environment. The hush syntax doesn't allow for setting all kinds of environment variables though, e.g. 5c00a000.tamp@5c00a000:reboot-mode.of.param can't be set with hush, because of the special characters. It could still be read by using the ${variable} syntax though. Allow setting these variables by making the setenv command generally available. The default is chosen to be 'y', because the command is deemed small and useful enough to have it there by default. Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* complete: remove unused variableAhmad Fatoum2019-08-301-2/+0
| | | | | | | instr_param serves no purpose in the function. Thus remove it. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* completion: Fix completion for devices with a dot in the nameSascha Hauer2016-10-071-8/+8
| | | | | | | Devices can have a dot in the name, so do not expect the full device name before the first dot. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* completion: fix device parameter completionSascha Hauer2015-08-071-16/+19
| | | | | | | | | With device parameter completion the '.' separator between the device name and the parameter was not handled correctly. For example with a device named global a completion starting with "g." was completed to "g.obal.". fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* treewide: fix 'new blank line at EOF' formatting errorAntony Pavlov2015-07-021-1/+0
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* complete: Add devicetree completionSascha Hauer2014-05-191-0/+71
| | | | | | | | The of_* commands take devicetree nodes as parameters. Add a devicetree completion function to ease passing nodes to these commands. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* complete: Fix completion after optionsSascha Hauer2014-05-191-0/+5
| | | | | | | | | | | | | the command specific complete callbacks only work when no option is typed already. For example "devinfo <tab><tab>" correctly completes the devices, but "devinfo -x <tab><tab>" does nothing. That is because the options are passed to the input string of the completion handlers. Skip the option string by finding the last space in the input string. This is not perfect since "devinfo -f<tab><tab>" still does not work, but it's better than what we have now. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* environment variables: use linux listSascha Hauer2012-10-301-5/+7
| | | | | | | | This switches environment variables to use linux list. This is easier to read. An additional plus is that the environment variables no longer need an initcall, so malloc is the only requirement for them. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Treewide: remove address of the Free Software FoundationSascha Hauer2012-09-171-3/+0
| | | | | | | The FSF address has changed in the past. Instead of updating it each time the address changes, just drop it completely treewide. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* complete: add missing EXPORT_SYMBOL for {command, device, empty, ↵Jean-Christophe PLAGNIOL-VILLARD2012-07-251-0/+4
| | | | | | | command}_var_complete Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/menu'Sascha Hauer2012-07-021-1/+1
|\
| * complete: fix parameter complete with multiple '.'Sascha Hauer2012-06-301-1/+1
| | | | | | | | | | | | | | When a device parameter has dots in its name, we have to use strchr instead of strrchr, because the devicename ends at the first dot, not at the last one. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | common: fix typo cammand_var_completeSteffen Trumtrar2012-06-301-1/+1
|/ | | | | | | Change function name to command_var_complete in all calls and its declaration. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* complete: fix duplicate env eval listJean-Christophe PLAGNIOL-VILLARD2012-05-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this can be reproductable by this sequence barebox:/ <TAB> . ? [ addpart bootm cat cd clear cp cpuinfo crc32 delpart devinfo dhcp echo edit erase ethact exit export false getopt go help host loadb loadenv loady login ls md md5sum memcmp memcpy meminfo memset menu mkdir mount mtest mw nfs passwd ping printenv protect pwd readline reset rm rmdir saveenv sedit sh sha1sum sha256sum sleep source test tftp time timeout true umount uncompress unprotect version net.nameserver= net.domainname= cs0.baudrate= cs0.active= cs1.active= cs1.ip= cs1.port= barebox:/ $<TAB> $net.nameserver $net.domainname $cs0.baudrate $cs0.active $cs1.active $cs1.ip $cs1.port $net.nameserver $net.domainname $cs0.baudrate $cs0.active $cs1.active $cs1.ip $cs1.port barebox:/ $ Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* complete: add executable file supportJean-Christophe PLAGNIOL-VILLARD2012-04-301-11/+19
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* complete: add go and sleep supportJean-Christophe PLAGNIOL-VILLARD2012-04-301-0/+5
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* complete: add empty complete supportJean-Christophe PLAGNIOL-VILLARD2012-04-301-0/+5
| | | | | | | | | | for cpuinfo, clear, dhcp, false, login, lsmod, meminfo, passwd, pwd, reginfo, reset, true, usb, version for mach-imx and mach-mxs: dump_clocks for u_serial: mycdev Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* complete: add device name complete support for devinfoJean-Christophe PLAGNIOL-VILLARD2012-04-301-0/+20
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* complete: add generic command complete frameworkJean-Christophe PLAGNIOL-VILLARD2012-04-301-15/+40
| | | | | | introduce generic command specific complete callback Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* complete: add var and device param complete supportJean-Christophe PLAGNIOL-VILLARD2012-04-301-6/+90
| | | | | | with $xx or xx= or if device $xx.yy or xx.yy= Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* auto-completion: add auto-completion for path filesAlexander Aring2011-12-211-2/+68
| | | | | | | Add auto-completion for path files. Signed-off-by: Alexander Aring <a.aring@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* remove typedef cmd_tbl_t and replace it with struct commandSascha Hauer2010-02-011-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* list: remove duplicated list.hSascha Hauer2009-11-031-1/+1
| | | | | | | | We accidently have two list implementations in the tree: include/list.h and include/linux/list.h. This patch moves the latter (newer one) to include/linux/list.h. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* use newly introduced stringlist functions for tab completionSascha Hauer2008-03-111-48/+15
|
* implement TAB completionSascha Hauer2008-03-011-0/+210