Merge branch 'command-subpackage' into 'master'

Command subpackage

See merge request !3
This commit is contained in:
Fredric Silberberg 2015-03-03 12:45:30 -05:00
commit 0f7fefe163
10 changed files with 27 additions and 22 deletions

View File

@ -1,7 +1,7 @@
from psh.commands import registered_cmds
from psh.commands.core import registered_cmds
# Import the exported commands
from psh.example_cmd import *
from psh.commands import *
# Instantiate the registered commands
for name, cls in registered_cmds.items():

3
psh/commands/__init__.py Normal file
View File

@ -0,0 +1,3 @@
from psh.commands.echo import *
from psh.commands.example import *
from psh.commands.raw import *

View File

@ -1,20 +1,8 @@
from psh.commands import BaseCommand, register_cmd
from psh.commands.core import BaseCommand, register_cmd
from psh.tree import TreeNode
@register_cmd("example")
class Example(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 TreeNode(b'example')
yield TreeNode(b'command')
return output_generator
@register_cmd("echo")
class Echo(BaseCommand):
"""Echoes anything from the command line arguments as well as input

15
psh/commands/example.py Normal file
View File

@ -0,0 +1,15 @@
from psh.commands.core import BaseCommand, register_cmd
from psh.tree import TreeNode
@register_cmd("example")
class Example(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 TreeNode(b'example')
yield TreeNode(b'command')
return output_generator

View File

@ -1,4 +1,4 @@
from psh.commands import BaseCommand
from psh.commands.core import BaseCommand
class Printer(BaseCommand):

View File

@ -1,6 +1,6 @@
import shlex
from psh.formatters import Printer
from psh.commands.formatters import Printer
from psh.commands import BaseCommand
from psh.tree import TreeNode

View File

@ -3,7 +3,7 @@ import code
import os
import readline
from psh.commands import registered_cmds
from psh.commands.core import registered_cmds
DEFAULT_HISTORY_FILE = "~/.psh_history"

View File

@ -1,10 +1,9 @@
import os
import os.path
from psh.formatters import *
from psh.commands.formatters import Printer
from psh.example_cmd import Echo, Example
from psh.raw_commands import RawCommand
from psh.commands import Echo, Example, RawCommand
# Load all of the commands in the path into the global namespace as raw
# commands.

View File

@ -1,4 +1,4 @@
from psh.commands import BaseCommand
from psh.commands.core import BaseCommand
from io import StringIO