Hey there,I'm new to programming. I'm working on this project and I want to add to it slash commands (e.g /help /show etc.).Any ideas on how to do it?Any help would be very appreciated.
|
Python
adding CLI function to my code. |
(Oct 29, 2018 01:19 PM)Meedman Wrote: Look about raw_input() function I hope it will help you :) I'll check it out later bud.Thanks for helping me.
There's surprisingly no great utility for this. The go-to most people use is the "cmd" package. It's simple and it's built into the standard library. But it's not super intuitive or particularly well-documented. There are better tutorials on blogs and stuff than there are on the docs.python.org page.
SRPP Discord Server
I am a professional network/cloud security architect. My Old Tutorials
well there's either an object-oriented way to pursue it where you view everything like a parser and lexer would, parse it initially, tokenize it, separate operands, determine types, detect strings, etc.; a more than-usual advanced parser, but worth it in the end.
i have some code-based resources (which probably aren't useful if you're at the degree of python i assume you are), but good luck: parsing strings parsing general tokens parsing octal/hex/denary-based integers
Contact for professional programming services.
unazed#5906
I think I have an idea what you mean, check this out and tell me if it's what you were going for.
Code # User input asking for a commandI think this is what you're trying to do? Let me know if I'm mistaken
Oct 30, 2018 11:37 AM
(This post was last modified: Oct 30, 2018 11:38 AM by giwrgosev.)
(Oct 29, 2018 03:25 PM)Goodies Wrote: There's surprisingly no great utility for this. The go-to most people use is the "cmd" package. It's simple and it's built into the standard library. But it's not super intuitive or particularly well-documented. There are better tutorials on blogs and stuff than there are on the docs.python.org page. thanks for your feedback bud.Will consider this. (Oct 29, 2018 06:34 PM)Infamia Wrote: well there's either an object-oriented way to pursue it where you view everything like a parser and lexer would, parse it initially, tokenize it, separate operands, determine types, detect strings, etc.; a more than-usual advanced parser, but worth it in the end. thanks for your help.I believe argparse is what I waas looking for. (Oct 30, 2018 10:08 AM)dv989 Wrote: argparse might help -- you can add something such as... Thank you mate, I almost lost all hope after reading someone say "there is no nice way" or something like that lmao This is python, almost everything has a built-in way User argparse and sys libs, get the args from sys.argv
Oct 31, 2018 01:38 PM
(This post was last modified: Oct 31, 2018 01:39 PM by giwrgosev.)
(Oct 30, 2018 06:41 PM)Keat Wrote: If you are using python 2.x then cmd module is good. If you are on 3 then use cmd2. ofc buddy,thanks for your help. (Oct 30, 2018 01:13 PM)dontspamthisplease Wrote: Thank you mate, I almost lost all hope after reading someone say "there is no nice way" or something like that lmao thats what i thought,thanks. |
|
|



