Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3222602
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:00:36+00:00 2026-05-17T16:00:36+00:00

I have already developed class1.py, class2.py, etc. with functions implemented inside each class. e.g.

  • 0

I have already developed class1.py, class2.py, etc. with functions implemented inside each class. e.g. Operator.py has add, minus, time, divide functions. How can I build a command line interface for these classes?

Also for this CLI, is it an infinite loop inside the main() for interaction?

And how can the CLI give some feedback such as, suggesting the user for the next operation or to input right command or type --help and check all the available commands, like the Bash shells?

Also it seems there is the optparse module from Python. Are there some good, complete, or high quality samples showing how a CLI is built? I would like to take this chance to learn how to write a CLI program.

I have already developed several classes, and also a GUI to call the methods from these classes. Now I want to have a CLI, like the GUI, to use these classes. e.g. I have classes like CDContainer (with method like addCD, removeCD, etc), CD (with method like play, stop, pause), and I have a GUI that could be interacted. Now I want to have a CLI, which under the bash, I could run this CLI and call createCDContainer, addCD, removeCD commands.

If I use cmd,

class CDContainerCLI(cmd.Cmd):
            
    def do_CDContainer(self, line):
        print "create CD container"

    def do_addcd(self, line):
        print "add cd into the container"

how do I add some options here? e.g., I want to addcd --track 3 --cdname thriller.

I think --track 3 --cdname thriller they are the 4 arguments for the addcd function. How to implement that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T16:00:36+00:00Added an answer on May 17, 2026 at 4:00 pm

    Derive from cmd.Cmd, overriding the various methods as necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have developed a JSP web application which, on every request, spawns a new
I've developed a JS-heavy site using the Mootools library and have hit a bump
I have a multi-language system, and all over the place I have what I
I've got 2 applications (lets call them AppA and AppB) communicating with each other.
I've developed an application making intense use of runtime memoization. I'd like to convert
All this might look too trivial but read it through - I have simple
HI, guys. I am using cmd and optparse to develop a CLI.py for a
Is there anyway to implement an repository that uses active directory (or any other
I'm refactoring for a client an app that should support OpenID, Facebook Connect and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.