I'm working on a command line interface. The user enter a commands such as
This would add a "song" with the -s
flag
add -s TITLE ARTIST
This would add an "album" with a -a
flag
add -a TITLE ARTIST
There are different flags and different commands like delete as well.
I've done this to evaluate the commands and flag, however I'm having trouble getting the rest of the string. The user input is taken in as an array of char, which I convert into a string.
if (inputString.substr(0, 3) == "add"){
if (inputString.substr(4, 5) == "-s"){
cout << "TEST: ADD SONGS" << endl;
//PROBLEM IS THIS LINE
cout << inputString.substr(6, MAX_LENGTH) << endl;
}
Whenever I get the command + action flag, I'd like to run a new function using the rest of the string to actually add the information into the database.
There is no problem when I typeadd -s
The program knows I want to add a song from evaluating the first characters. However if I type in more such as "add -s "Sorry" "Justin Bieber"
The program doesn't even acknowledge that the add -s flag was run.
Can someone explain why this is and how I can change it? Stuck on it for a while now.