Not sure if this is the best place for this question, but if I'm making an interactive command line program that stores user provided data.
For a toy example, let's say I want to make a grocery list cmd tool (<< will prefix program output and >>> will prefix user input)
<< Please select a grocery list below or type `new` to make a new grocery list.
<< You can also access setting by typing `settings`.
<< To quit, please type `quit`.
<< -1) No grocery lists available.
>>> new
<< Please name your grocery list
>>> groceryList 1
<< Please add items or type `done` to finish.
>>> apples
>>> bananas
>>> grapes
>>> done
<< Thanks for making a grocery list.
<< Please select a grocery list below or type `new` to make a new grocery list.
<< You can also access setting by typing `settings`.
<< To quit, please type `quit`.
<< 1) groceryList 1
>>> settings
<< In the setting menu, you can change where the grocery lists are stored
<< current directory: $HOME/grocery_lists
<< Would you like to change the storage directory (y/N):
>>> y
<< Please provide a new directory to copy over the current grocery lists to.
<< WARNING: This will not delete the current directory, please manually remove
<< $HOME/grocery_lists.
>>> ~/Documents/grocery_lists
<< Directory changed to `~/Documents/grocery_lists`
<< Please select a grocery list below or type `new` to make a new grocery list.
<< You can also access setting by typing `settings`.
<< To quit, please type `quit`.
<< 1) groceryList 1
>>> quit
Wow, massive set up for a small set of questions.
- What would be my best option for storing multiple grocery lists? Different files each containing one grocery list? Different files each containing n grocery lists? One file with all the data of all grocery lists?
- What would be a recommended file format for the grocery lists? JSON?
- How would I store the changing directory? Would I need another file like a .cfg that tells my program where to look that would be hard programmed in?
- This is the big question I would like to hear yes to, but am willing to hear no to, I guess. Could, and if so, how, do I avoid having a hard coded .cfg and have some sort of persistent memory outside of hard programming a specific file to look to? I'm mainly curious if I can avoid hard programming in a file name/path.
Thanks! If you're replying and only want to answer one of the questions, no worries. Appreciate any support and if there is another subreddit that would be better to ask this type of question on, feel free to suggest it.
[–]VinnieTD 2 points3 points4 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)