dotnetdeveloperaz / MetalPriceConsole

Simple console application to get the closing price of gold, silver, palladium or platinum for the previous day. Can be scheduled to run daily or used manually..
0 stars 0 forks source link

Allow specifying cache file #57

Closed dotnetdeveloperaz closed 4 months ago

dotnetdeveloperaz commented 10 months ago

Possibly add a switch to load/save a cache file from any path location instead of just the default. This would also override the default cache file name.

eg: instead of \MetalPrice.cache someone could specify --cachefile \Temp\MyFile.json or whatever they choose.

dotnetdeveloperaz commented 10 months ago

Going to make this for relative paths, so no support for specifying drives in Windows. Technically, this feature isn't needed, but it could be nice to have one offs to save a cache file in a specific location for testing that is different from the default for scheduled tasks. This would also allow someone to have multiple scheduled tasks that store data in a cache file, and one for each metal, although not necessary either since you can specify what to show anyway. When using the view command, you can show all metals or a specific metal. Mutiple metals is not supported as the API is still an individual call for each, but maybe in the future we can add functionally for that.

dotnetdeveloperaz commented 10 months ago

Just a note, this will use relative forward slash notations which works cross platform to negate the need to escape the path deliminters in the json file (eg: /temp/myfile.cache vs \temp\myfile.cache)

dotnetdeveloperaz commented 4 months ago

Need to look into creating an option parameter for --cache <path/file> instead of how I implemented it which currently makes you specify --cache --file <path/file>. This really isn't necessary if we can have optional parameters so that if you just specify --cache it uses the default, but if you specify the path and file, it will use that. This would be used for --save and --view.

dotnetdeveloperaz commented 4 months ago

Need to look into creating an option parameter for --cache <path/file> instead of how I implemented it which currently makes you specify --cache --file <path/file>. This really isn't necessary if we can have optional parameters so that if you just specify --cache it uses the default, but if you specify the path and file, it will use that. This would be used for --save and --view.

Ok, this is not possible as it doeesn't support having --cache <path/file> while also doing a boolean, which we need to know if we're using cache or not for saving, and it's not just for restore and view.

dotnetdeveloperaz commented 4 months ago

Need to look into creating an option parameter for --cache <path/file> instead of how I implemented it which currently makes you specify --cache --file <path/file>. This really isn't necessary if we can have optional parameters so that if you just specify --cache it uses the default, but if you specify the path and file, it will use that. This would be used for --save and --view.

Ok, this is not possible as it doeesn't support having --cache <path/file> while also doing a boolean, which we need to know if we're using cache or not for saving, and it's not just for restore and view.

Also, one more note. It actually makes sense to have it this way as if someone wants to override the cache file for a specific run and doesn't want to change their configured path/file, but they are not using -cache but still using --save, if there is a failure writing to database, it would use the specified cache file instead of the default/configured one.