Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python

License

NotificationsYou must be signed in to change notification settings

python-cmd2/cmd2

Repository files navigation

Latest VersionGitHub ActionscodecovDocumentation StatusChat

Developer's ToolboxPhilosophyInstallationDocumentationTutorialsHello WorldProjects using cmd2

Screenshot

cmd2 is a tool for building interactive command line applications in Python. Its goal is to make itquick and easy for developers to build feature-rich and user-friendly interactive command lineapplications. It provides a simple API which is an extension of Python's built-incmd module. cmd2 provides a wealth of features on topof cmd to make your life easier and eliminates much of the boilerplate code which would be necessarywhen using cmd.

⚠️cmd2 is now "feature complete" for the2.x branch and is actively working on the3.0.0 release on themain branch. New features will only be addressed in 3.x moving forwards. Ifneed be, we will still fix bugs in 2.x.

The developers toolbox

system schema

When creating solutions developers have no shortage of tools to create rich and smart userinterfaces. System administrators have long been duct taping together brittle workflows based on amenagerie of simple command line tools created by strangers on github and the guy down the hall.Unfortunately, when CLIs become significantly complex the ease of command discoverability tends tofade quickly. On the other hand, Web and traditional desktop GUIs are first in class when it comesto easily discovering functionality. The price we pay for beautifully colored displays is complexityrequired to aggregate disperate applications into larger systems.cmd2 fills the niche betweenhighease of command discovery applications and smartworkflow automation systems.

Thecmd2 framework provides a great mixture of both worlds. Application designers can easilycreate complex applications and rely on the cmd2 library to offer effortless user facing help andextensive tab completion. When users become comfortable with functionality, cmd2 turns into afeature rich library enabling a smooth transition to full automation. If designed with enoughforethought, a well implemented cmd2 application can serve as a boutique workflow tool.cmd2 pullsoff this flexibility based on two pillars of philosophy:

  • Tab Completion
  • Automation Transition

Philosophy

Deep extensive tab completion and help text generation based on the argparse library create thefirst pillar of 'ease of command discovery'. The following is a list of features in this category.

  • Great tab completion of commands, subcommands, file system paths, and shell commands.
  • Custom tab completion for user designed commands via simple function overloading.
  • Tab completion frompersistent_history_file sources added with very little friction.
  • Automatic tab completion ofargparse flags and optional arguments.
  • Path completion easily enabled.
  • When all else fails, custom tab completion based onchoices_provider can fill any gaps.

cmd2 creates the second pillar of 'ease of transition to automation' through alias/macro creation,command line argument parsing and execution of cmd2 scripting.

  • Flexible alias and macro creation for quick abstraction of commands.
  • Text file scripting of your application withrun_script (@) and_relative_run_script (@@)
  • Powerful and flexible built-in Python scripting of your application using therun_pyscriptcommand
  • Transcripts for use with built-in regression can be automatically generated fromhistory -t orrun_script -t

Installation

On all operating systems, the latest stable version ofcmd2 can be installed using pip:

pip install -U cmd2

cmd2 works with Python 3.9+ on Windows, macOS, and Linux. It is pure Python code with few 3rd-partydependencies. It works with both conventional CPython and free-threaded variants.

For information on other installation options, seeInstallation Instructions in thecmd2 documentation.

Documentation

The latest documentation for cmd2 can be read online here:https://cmd2.readthedocs.io/en/latest/

It is available in HTML, PDF, and ePub formats.

The best way to learn the cmd2 api is to delve into the example applications located in source underexamples.

Tutorials

Hello World

#!/usr/bin/env python"""A simple cmd2 application."""importcmd2classFirstApp(cmd2.Cmd):"""A simple cmd2 application."""defdo_hello_world(self,_:cmd2.Statement):self.poutput('Hello World')if__name__=='__main__':importsysc=FirstApp()sys.exit(c.cmdloop())

Found a bug?

If you think you've found a bug, please first read through the openIssues. If you're confident it's a new bug, go aheadand create a new GitHub issue. Be sure to include as much information as possible so we canreproduce the bug. At a minimum, please state the following:

  • cmd2 version
  • Python version
  • OS name and version
  • What you did to cause the bug to occur
  • Include any traceback or error message associated with the bug

Projects using cmd2

Application NameDescriptionOrganization or Author
PobshellA Bash‑like shell for live Python objects:cd,ls,cat,find andCLI piping for object code, str values & morePeter Dalloz
CephFS ShellThe Ceph File System, or CephFS, is a POSIX-compliant file system built on top of Ceph’s distributed object storeceph
garakLLM vulnerability scanner that checks if an LLM can be made to fail in a way we don't wantNVIDIA
medusaBinary instrumentation framework that that automates processes for the dynamic analysis of Android and iOS ApplicationsCh0pin
InternalBlueBluetooth experimentation framework for Broadcom and Cypress chipsSecure Mobile Networking Lab
SCCMHunterA post-ex tool built to streamline identifying, profiling, and attacking SCCM related assets in an Active Directory domainGarret Foster
UnipackerAutomatic and platform-independent unpacker for Windows binaries based on emulationunipacker
FrankensteinBroadcom and Cypress firmware emulation for fuzzing and further full-stack debuggingSecure Mobile Networking Lab
PoseidonLeverages software-defined networks (SDNs) to acquire and then feed network traffic to a number of machine learning techniques.Faucet SDN
DFTimewolfA framework for orchestrating forensic collection, processing and data exportlog2timeline
GAP SDKSDK for Greenwaves Technologies' GAP8 IoT Application ProcessorGreenWaves Technologies
REW SploitEmulate and Dissect Metasploit Framework (MSF) and other attacksREW-sploit
tomcatmanagerA command line tool and python library for managing a tomcat servertomcatmanager
Falcon ToolkitUnleash the power of the CrowdStrike Falcon Platform at the CLICrowdStrike
EXPLIoTInternet of Things Security Testing and Exploitation frameworkexpliot_framework

Possibly defunct but still good examples

Application NameDescriptionOrganization or Author
KatanaAutomatic CTF Challenge SolverJohn Hammond
SatanSword (in Chinese)Comprehensive Penetration Framework for Red TeamingLucifer1993
Jok3rNetwork & Web Pentest Automation FrameworkKoutto
Counterfita CLI that provides a generic automation layer for assessing the security of ML modelsMicrosoft Azure
OverlordRed Teaming Infrastructure AutomationQSecure Labs
Automated Reconnaissance PipelineAn automated target reconnaissance pipelineepi052
JSShellAn interactive multi-user web JavaScript (JS) shellDen1al
RedShellAn interactive command prompt for red teaming and pentestingVerizon
FLASHMINGOAutomatic analysis of SWF files based on some heuristics. Extensible via plugins.Mandiant
psiTurkAn open platform for science on Amazon Mechanical TurkNYU Computation and Cognition Lab

Note: If you have created an application based oncmd2 that you would like us to mention here,please get in touch.

About

cmd2 - quickly build feature-rich and user-friendly interactive command line applications in Python

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp