1
0
Fork 0
mirror of synced 2024-06-28 02:50:27 +12:00

Add --config option for explicitly stating configuration file to use.

aliparlakci/bulk-downloader-for-reddit#122

Address comments in pull review.

* Removed vertical space.
* Added config file existence check with log message.
This commit is contained in:
Robert Pufky 2020-06-07 13:01:26 -07:00
parent 2ba763e03b
commit 37a3d83725
3 changed files with 34 additions and 13 deletions

View file

@ -181,6 +181,14 @@ Takes a file directory as a parameter and skips the posts if it matches with the
Example usage: **`--downloaded-posts D:\bdfr\ALL_POSTS.txt`**
## **`--config`**
Specify a `config.json` file to use. This will disable reading from the default `Bulk downloader for reddit/config.json` file, as well as `--use-local-config` option.
Example usage: **`--config /etc/bdfr/config.json`**
Example usage: **`-c ~/config.json`**
Example usage: **`--config c:\Users\Me\Downloads\config.json`**
Example usage: **`-c c:\config.json`**
## ❔ FAQ
### I am running the script on a headless machine or on a remote server. How can I authenticate my reddit account?

View file

@ -256,10 +256,20 @@ def printLogo():
)
def main():
arguments = Arguments.parse()
GLOBAL.arguments = arguments
if arguments.config:
if arguments.use_local_config:
sys.exit()
if Path(arguments.config).exists():
GLOBAL.configDirectory = Path(arguments.config)
else:
VanillaPrint("custom config",arguments.config,"not found. Exiting.")
sys.exit()
else:
if not Path(GLOBAL.defaultConfigDirectory).is_dir():
os.makedirs(GLOBAL.defaultConfigDirectory)
if Path("config.json").exists():
GLOBAL.configDirectory = Path("config.json")
else:
@ -274,9 +284,6 @@ def main():
sys.argv = sys.argv + GLOBAL.config["options"].split()
arguments = Arguments.parse()
GLOBAL.arguments = arguments
if arguments.set_filename:
Config(GLOBAL.configDirectory).setCustomFileName()
sys.exit()

View file

@ -154,6 +154,12 @@ class Arguments:
help="Just saved posts into a the POSTS.json file without downloading"
)
parser.add_argument("--config","-c",
help="Specify exact config.json file to use. " \
"Disables reading from 'Bulk downloader for " \
"reddit/config.json' and --use-local-config " \
"option."
)
if arguments == []:
return parser.parse_args()