Questions tagged [cmd2]

cmd2 is a tool for building interactive command line applications in Python

12 questions
2
votes
0 answers

Suppressing cmd warning message

When entering a shell I always get the following warning message from cmd2: Desktop david$ python3 client.py Readline features including tab completion have been disabled because no supported version of readline was found. To resolve this,…
David542
  • 104,438
  • 178
  • 489
  • 842
1
vote
0 answers

Intermittent pytest failures complaining about missing tcl files even though the files are there

Tools: Python 3.10, cmd2 2.4.0, Windows 11, tk 0.1.0, matplotlib 3.5.1, pytest 7.0.1, cmd2-ext-test 2.0.0 I am building a set of pytest tests that cover code which normally outputs plots using matplotlib (backend="TkAgg"). This code is using cmd2 so…
jwcoder
  • 131
  • 9
1
vote
0 answers

Possible to auto-insert a prefix as a hack in cmd2?

I would like the default command in the repl to allow multi-lines. However, in cmd2 you have to specify the actual command that is multi-line, which defeats the purpose in the above. Here is an example I have thus far, but it requires inserting a…
David542
  • 104,438
  • 178
  • 489
  • 842
1
vote
1 answer

Argparse + cmd2 RecursionError even on simple programs

Sample code: import argparse import cmd2 import sys def create_subparser(a_parser = None): if a_parser is None: new_parser = argparse.ArgumentParser() else: new_parser = a_parser.add_parser("single") …
wewlad
  • 11
  • 1
1
vote
1 answer

How to always enable debug in a Python Cmd2 App?

I am using the Cmd2 module in Python (version 1.0.2) to build a command-line interface (CLI). After I run the program (so that I am inside my custom CLI), if I want debugging to be enabled so that it shows stack traces on errors, I have to manually…
jwcoder
  • 131
  • 9
1
vote
1 answer

Python cmd module: get the whole input in default method

I'm working on an cmd2 interface to my database and I want to be able to use it to quickly and continuously enter data into my database. I therefore want to do the inserts in the default method of cmd2. def default(self, line): data =…
1
vote
0 answers

CLI clearing screen every time I push a key

I upgraded from cmd to cmd2 and I am running into a issue. My application is a server and once it receives a connection it prints the following to the screen. Connected with 127.0.0.1:56653 Now I am using netcat for testing as the client for…
Doritos
  • 403
  • 3
  • 16
1
vote
0 answers

How do I do tab completion for a directory argument using argparse in cmd2?

I am using cmd2 to write an interactive Python application. I use the @with_argparser decorator for argument parsing. One of my do_ action arguments is a directory. I would like tab completion to suggest directories. I know how to set up tab…
W.P. McNeill
  • 16,336
  • 12
  • 75
  • 111
0
votes
0 answers

python cmd2 multiarg parser

I have 4 arguments eg: a,b,c,d. Users have the option to enter a or b or c or d else a or c else enter 'a' only or 'd' only like that follow all probability. for that how to write the argument parser. subscription_parser =…
0
votes
1 answer

How to autocomplete only one argument in Cmd2 with argparse

How to autocomplete one argument in argument parser with cmd2. from cmd2 import Cmd, Cmd2ArgumentParser import cmd2 numbers = ['0', '1', '2', '3', '4'] alphabet = ['a', 'b', 'c', 'd'] class Complete(Cmd): parser = Cmd2ArgumentParser() …
Nazime Lakehal
  • 1,542
  • 1
  • 11
  • 15
0
votes
0 answers

Python interactive shell with cmd or cmd2 variables?

I am using cmd library to design the python interactive tool (shell). My requirement is to provide variables and store values against variables. Is it possible in the cmd or cmd2 library? >> get_values **A_VARIABLE 100 B_VARIABLE 200** Expectation…
scott
  • 35
  • 5
0
votes
0 answers

Capture do function results inside cmd2

Here is a simple script using the Python cmd2 library. import cmd2 class App(cmd2.Cmd): result = 0 # Long computation def do_add3(self, arg): r = 3 + int(arg) print(r) self.result = r # Scripting def do_test(self, arg): …
Zhe Hu
  • 3,777
  • 4
  • 32
  • 45