Here is something. I added a few commands like DIR or ping. Also, recursion is not good. While loop is better.
import socket
import time
import os
import platform # For getting the operating system name
import subprocess # For executing a shell command
def ping(host,num="4"):
"""
Returns True if host (str) responds to a ping request.
Remember that a host may not respond to a ping (ICMP) request even if the host name is valid.
"""
# Option for the number of packets as a function of
param = '-n' if platform.system().lower()=='windows' else '-c'
# Building the command. Ex: "ping -c 1 google.com"
command = ['ping', param, num, host]
return subprocess.call(command) == 0
HOSTNAME = socket.gethostname()
CREDITS = "Developed by SnoDev"
print("Welcome " + HOSTNAME + "!")
time.sleep(1)
while True:
var1=input("Command Bar: ")
if "ping" in var1.lower():
var2=var1.lower().split()
if len(var2)==1:
print("Usage: ping [-number]\n\nOptions:\n\t-number\t\tPing the host for specified number of times.\n")
elif len(var2)==3:
print(ping(var2[1],var2[2][1:]))
#print(ping(var2[1],var2[2]))
else:
print(ping(var2[1]))
elif var1.lower()=="exit":
break
elif "dir" in var1.lower():
var3=var1.lower().split()
if len(var3)==1:
print("Usage: DIR [-path]\n\nOptions:\n\t-path\t\tList all folders and files inside the specified directory.\n")
else:
x=os.listdir(var3[1])
print("\nDirectories and files found: \n")
for i in x:
print(i)
print("\n")
elif var1=="":
pass
else:
print(f"Error: {var1} is not recognized as a command.\n")