[5/8] header-config: add generic hhok_hid function

Message ID 1500998833-10543-6-git-send-email-jonatan.schlag@ipfire.org
State New
Headers show

Message

Jonatan Schlag July 25, 2017, 4:07 p.m.
This function will always be there so when we call hhok_hid we will get a result.
This is also nice for testing.

Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
---
 src/header-config | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Michael Tremer July 25, 2017, 10:29 p.m. | #1
On Tue, 2017-07-25 at 18:07 +0200, Jonatan Schlag wrote:
> This function will always be there so when we call hhok_hid we will get a
> result.
> This is also nice for testing.
> 
> Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
> ---
>  src/header-config | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/src/header-config b/src/header-config
> index e3c6423..76f4bb5 100644
> --- a/src/header-config
> +++ b/src/header-config
> @@ -76,3 +76,11 @@ hook_edit() {
>  
>  	exit ${EXIT_OK}
>  }
> +
> +# We will return the id as generic variant of the hid
> +# Although this should not be the standard
> +hook_hid() {
> +	assert [ $# -eq 1 ]
> +	local config=${1}
> +	echo $(config_get_id_from_config ${config})
> +}

Just call "config_get_if_from_config ${config}".

Doesn't need the echo.

Also remove the assert here. The hook should always assume that it is being
called with the correct number of arguments and this will also make auto-
completion slower.

-Michael