Softpedia
 


LINUX CATEGORIES:



GLOBAL PAGES >>
NEWS ARCHIVE >>
SOFTPEDIA REVIEWS >>
MEET THE EDITORS >>
WEEK'S BEST
  • Linux Kernel 3.9.6 / 3....
  • Linux Kernel 3.0.82 LTS...
  • KDE Software Compilatio...
  • PulseAudio 4.0
  • Wireshark 1.10.0
  • NetworkManager 0.9.8.2
  • LibreOffice 3.6.6 / 4.0...
  • SystemRescueCd 3.7.0
  • Linux Kernel 3.10 RC6
  • Ubuntu Tweak 0.8.5
  • Home > Linux > Programming > Libraries

    kmd 2.2

    Download button

    No screenshots available
    Downloads: 222  View global page NEW!  Tell us about an update
    User Rating:
    Rated by:
    NOT RATED
    0 user(s)
    Developer:

    License / Price:

    Last Updated:

    Category:
    Stefan H. Holek | More programs
    GPL / FREE
    May 14th, 2012, 11:20 GMT [view history]
    ROOT / Programming / Libraries

     Read user reviews (0)  Refer to a friend  Subscribe

    kmd description

    A modern version of cmd.Cmd using rl readline bindings

    kmd is a Python module that allows to easily build command-line driven shells with powerful TAB-completion capabilities.

    The kmd.Kmd class derives from cmd.Cmd and modifies it in the following ways:

    1. Instead of Python's readline module, kmd.Kmd uses the alternative rl readline bindings.
    2. Setup and tear-down of the readline completer have been moved to preloop and postloop respectively. Subclasses must now make sure to call their parent's implementations.
    3. Lines starting with '#' are treated as comments. The new comment method is invoked, passing the line as argument. By default this method clears the lastcmd.
    4. Incomplete command names are automatically expanded given they are unique.
    5. It is now possible to configure the shell_escape_characters. The default set is '!'.
    6. If a history_file is configured, kmd.Kmd loads and saves the history during preloop and postloop.
    7. The new run method encapsulates execution of a kmd.Kmd.

    Package Contents

    kmd.Kmd
     Implements the mechanics of a command shell, similar to cmd.Cmd.

    kmd.completions
     Implements a set of ready-to-use completions.

    Completions

    FilenameCompletion
     Complete file and directory names.

    UsernameCompletion
     Complete user names.

    EnvironmentCompletion
     Complete environment variables.

    CommandCompletion
     Complete system commands.

    Example Code

    import os
    import kmd

    from kmd.completions.filename import FilenameCompletion
    from kmd.completions.environment import EnvironmentCompletion

    class MyShell(kmd.Kmd):

     def preloop(self):
     super(MyShell, self).preloop()
     self.completefilename = FilenameCompletion()
     self.completeenviron = EnvironmentCompletion()

     def do_echo(self, args):
     os.system('echo ' + args)

     def complete_echo(self, text, line, begidx, endidx):
     return self.completeenviron(text)

     def do_cat(self, args):
     os.system('cat ' + args)

     def complete_cat(self, text, line, begidx, endidx):
     return self.completefilename(text)

    def main():
     MyShell().run()


    Also see gpgkeys, a front-end for GnuPG built entirely around tab completion.

    Repository Access

    kmd development is hosted on github.

    Installation

    kmd uses the rl library. Since rl contains a C extension, it is a good idea to review its installation instructions and make sure all dependencies are in place.

    To install the kmd package, type:

    easy_install kmd


    Product's homepage

    Requirements:

    · Python

    What's New in This Release: [ read full changelog ]

    · String and filename quoting was not respected when Kmd.run was called with arguments. [stefan]
    · Switch to a happier looking Sphinx theme. [stefan]
    · Require rl >= 2.2. [stefan]

      


    TAGS:

    readline bindings | command-line shells | command-line | readline | bindings

    Go to top

    WindowsGamesDriversMacLinuxScriptsMobileHandheldNews

    SUBMIT PROGRAM   |   ADVERTISE   |   GET HELP   |   SEND US FEEDBACK   |   RSS FEEDS   |   UPDATE YOUR SOFTWARE   |   ROMANIAN FORUM