30350n / inventree_part_import

CLI to import parts from suppliers like DigiKey, LCSC, Mouser, etc. to InvenTree
MIT License
28 stars 8 forks source link

Supplier choices are invalid when using external config dir #19

Open QuadratClown opened 6 months ago

QuadratClown commented 6 months ago

When using supplier constrained input flags like -s or -o together with the -c flag, the cli will not use the provided config dir when deciding which suppliers are valid choices.

How to reproduce

From config folder, run:

inventree-part-import -c $pwd -o mouser <arbitraryPart>

Expected behaviour

Use config dir provided with -c for supplier choices

Real behaviour

Error: Invalid value for '-o' / '--only': 'mouser' is not one of .
30350n commented 6 months ago

Easiest way to fix this would be to simply also configure those suppliers in the default configuration. Alternatively you could also just use the default configuration directory, I mainly implemented the -c option to be able to quickly test things with different configurations.

30350n commented 6 months ago

Fixing this properly probably won't be that easy, because the checking isn't actually done by me, but by click so some restructuring would be required (the checking would have to be disabled and done manually).

QuadratClown commented 6 months ago

Thanks for the quick answer. An alternative way could be to make the default location configurable. Not sure how hard that is with click.

The whole thing is by no means a show stopper anyway, it's just not quite obvious where the error is coming from when not yet familiar with the inner workings of the cli.

30350n commented 6 months ago

No problem! Yeah the cause of the error is somewhat opaque. Any particular reason why you aren't just using the default directory btw?

QuadratClown commented 6 months ago

I'm using multiple devices with inventree and want to sync the config across them. On windows for example, the default folder is in AppData/Local, which I really dislike using for a purpose like this. Usually, I have just have a scripts folder that contain one folder per script with all necessary configs that I can just sync directly, platform independently.

30350n commented 6 months ago

Ah okay, well I'm just using whatever platformdirs.user_config_dir spits out. You could also try to symlink your custom folder into the default location. Pretty sure that should work too.

QuadratClown commented 6 months ago

The symlink approach is what I'm using for Kicad, guess then for here as well :) Thanks for your time!