from commands import BaseCommand, register_cmd @register_cmd class example_cmd(BaseCommand): """Simple command that just returns 'example' and 'command'. Does nothing at all with the input.""" def call(self, *args, **kwargs): def output_generator(): yield b'example' yield b'command' return output_generator @register_cmd class echo(BaseCommand): """Echoes anything from the command line arguments as well as input from the previous command.""" def __init__(self, args): super(echo, self).__init__() self.args = args def call(self,*args,**kwargs): input_generator = self.get_input_generator() def output_generator(): for args in self.args: yield args.encode("utf-8") for line in input_generator: yield line return output_generator