Table Of Contents

This Page

doit-cmd - documentation

Intro

Helper to create doit tasks that execute a command

Project Details

documentation

Helpers for creating tasks that exectue shell commands.

class doitcmd.BaseCommand(sudo=None, interactive=None, options=None)[source]

Base class to create tasks that execute a shell command.

It provides:

  • conversion of a param dict to a command options string
  • handle/control wheather the command should be as sudo
  • handle/control wheather the command is going to be execute interactively
Variables:
  • cmd_template (str) – python str template for command eg. install {opts} {source} {dest}
  • base_options (dict) – default command options
  • sudo (bool) – If True prepend sudo to command
  • Interactive (bool) – If True use doit.tools.Interactive on action.

Usage: see doitsys.copy.Copy

static opt_str(*opt_list)[source]

command line option formatter

Parameters:opt_list (list-dict) – list of dict with command options
Return string:formatted options for a command line

If the value of an option is True, option is added wihtout a value. If opt name lenght is just one characher use only one dash.

action(cmd_str)[source]

Modify action adding sudo / Interactive.

Parameters:cmd_str (str) – command string
Returns:An action for a doit task (might be a plain string)
__call__()[source]

return a task dictionary (to be implement on sub-class)

doitcmd.cmd(cmd_str, sudo=None, **task_params)[source]

short-cut to return a task that executes a simple command

Parameters:
  • cmd_str (str) – the command to be executed
  • sudo (bool) – execute to command as sudo
  • task_params (dict) – extra doit task params (file_dep, task_dep...)
Return dict:

doit task metadata

doitcmd.interactive(cmd_str, sudo=None, **task_params)[source]

short-cut to return a task that executes a simple command interactively

Parameters:
  • cmd_str (str) – the command to be executed
  • sudo (bool) – execute to command as sudo
  • task_params (dict) – extra doit task params (file_dep, task_dep...)
Return dict:

doit task metadata