Skip to content

Instantly share code, notes, and snippets.

@Oleksiy-Yakovenko
Last active September 17, 2021 06:28
Show Gist options
  • Save Oleksiy-Yakovenko/aa226803af604042721d671ecde94c3d to your computer and use it in GitHub Desktop.
Save Oleksiy-Yakovenko/aa226803af604042721d671ecde94c3d to your computer and use it in GitHub Desktop.
Deadbeef Proposal: passing command line arguments to plugins

Introduction

Some developers are interested in extending Deadbeef command line with more options.
Currently it's not supported, but the API is there, and it should be relatively easy to implement without breaking the existing plugins.

The proposal

  • Reuse the existing API: int (*exec_cmdline) (const char *cmdline, int cmdline_size);
  • Use it only with the plugins which use the API, which corresponds to deadbeef release which adds the feature.
  • The users will need to specify the plugin explicitly, if they want to use its command line.
  • The plugins will be fully responsible for interpreting the arguments, displaying help, and executing the actions.
  • Deadbeef will need to be extended with 2 new command line options:
    • --plugin=PLUGIN: set destination for the following command line arguments. main plugin should mean that arguments need to be directed to deadbeef itself, and is the default.
    • --plugin-list: list all plugin identifiers, with information whether the plugins support command line arguments
  • The --plugin and --plugin-list commands should be documented in the --help command output.

Implementation Details

The plugins will need to implement the exec_cmdline entry point. Command line should be passed as a buffer with \0-separated strings. This should not require any preprocessing logic, deadbeef will only need to figure out the range in the buffer.

How should the plugins output text?

The plugins should directly print to stdout / stderr, as needed.

What deadbeef should do when the command line specifies multiple commands which all output something?

Deadbeef (or plugins) should execute all commands, in the same order they appear on the command line.

Examples

deadbeef --plugin=PLUGIN [ command line args ]: execute command line on PLUGIN
deadbeef --plugin=PLUGIN1 [ command1 ] --plugin=PLUGIN2 [ command2 ]: execute command1 on PLUGIN1, and command2 on PLUGIN2
deadbeef --plugin=PLUGIN1 [ command1 ] --plugin=main [ command2 ]: execute command1 on PLUGIN1, and command2 as normal deadbeef command

Open Questions

Deadbeef doesn't use longopt-style command line arguments, which take parameters, such as --argument=parameter.
Mainly because it's simpler to interpret them as separate strings: --argument1\0parameter1\0--argument2\0parameter2\0.
However, the syntax with = sign is very commonplace, and will be expected by the users, so we should consider supporting it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment