简体   繁体   中英

How I take user input using args

I am working on my own custom terminal using python but I what want to take input using args [Ex: myterminalinput >>> Testcmd -c test -p test] how I do that I also created code but it's not working code:-

import argparse
import sys
import os
import colorama
from colorama import Fore, Style

usrin = input(Fore.GREEN +"┌─["+ Fore.RED + Style.BRIGHT +"Terminalx"+ Fore.GREEN +"@"+ Fore.CYAN             
+""+"shash"+ Fore.GREEN +"]"+"-"+ Fore.GREEN +"["+ Fore.RED +"win64"+ Fore.GREEN +"]\n"
                  + Fore.GREEN +"└──╼"+ Fore.CYAN + " >" + Fore.RED + ">" + Fore.GREEN + "> ")

dfclpth = ("C:\_tx-clonerep_")

def calc(args):
    if "git" == usrin:
        return os.system("git-clone.exe"+" "+ args.c + " " + args.p)
        print()

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', type=str, default='',
                        help="Enter Github repository url")
    parser.add_argument('-p', type=str, default="",
                        help="Enter repository cloning path")


    args = parser.parse_args()
    sys.stdout.write(str(calc(args)))

But its not working??

I am working on my own custom terminal using python but I what want to take input using args [Ex: myterminalinput >>> Testcmd -c test -p test] how I do that I also created code but it's not working code:-

import argparse
import sys
import os
import colorama
from colorama import Fore, Style

usrin = input(Fore.GREEN +"┌─["+ Fore.RED + Style.BRIGHT +"Terminalx"+ Fore.GREEN +"@"+ Fore.CYAN             
+""+"shash"+ Fore.GREEN +"]"+"-"+ Fore.GREEN +"["+ Fore.RED +"win64"+ Fore.GREEN +"]\n"
                  + Fore.GREEN +"└──╼"+ Fore.CYAN + " >" + Fore.RED + ">" + Fore.GREEN + "> ")

dfclpth = ("C:\_tx-clonerep_")

def calc(args):
    if "git" == usrin:
        return os.system("git-clone.exe"+" "+ args.c + " " + args.p)
        print()

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('-c', type=str, default='',
                        help="Enter Github repository url")
    parser.add_argument('-p', type=str, default="",
                        help="Enter repository cloning path")


    args = parser.parse_args()
    sys.stdout.write(str(calc(args)))

But its not working??

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM