Merge branch 'command-subpackage' into 'master'
Command subpackage See merge request !3
This commit is contained in:
commit
0f7fefe163
@ -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
3
psh/commands/__init__.py
Normal file
@ -0,0 +1,3 @@
|
||||
from psh.commands.echo import *
|
||||
from psh.commands.example import *
|
||||
from psh.commands.raw import *
|
@ -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
15
psh/commands/example.py
Normal 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
|
@ -1,4 +1,4 @@
|
||||
from psh.commands import BaseCommand
|
||||
from psh.commands.core import BaseCommand
|
||||
|
||||
|
||||
class Printer(BaseCommand):
|
@ -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
|
||||
|
@ -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"
|
||||
|
||||
|
@ -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.
|
||||
|
@ -1,4 +1,4 @@
|
||||
from psh.commands import BaseCommand
|
||||
from psh.commands.core import BaseCommand
|
||||
|
||||
from io import StringIO
|
||||
|
||||
|
Reference in New Issue
Block a user