Skip to content

Conversation

eeintech
Copy link
Contributor

@eeintech eeintech commented Jul 21, 2021

Based on my proposal in #66

Class

Basic Usage

from inventree_cli import InvenTreeCLI

# Define path to configuration file
config_file = '/home/user/inventree-python/config.yaml'

# Get API instance
inventree = InvenTreeCLI(config_file)

if inventree.api:
    # Execute GET operation on part table
    op = 'get'
    # Retrieve part using ID
    part = inventree.part(_function=op, id=145)
    print(part)
    # Retrieve part using name
    part = inventree.part(_function=op, name='RES SMD 100K OHM 1% 1/16W 0402')
    print(part)

CLI

Usage

Option 1

$ python inventree_cli.py --config <config_file> <table> --op <operation>

Option 2

$ pip install --editable .
$ inventree --config <config_file> <table> --op <operation>

Examples

Quick connection test

$ inventree --config config.yaml
Connecting... Connected.

Get list of operations for target table

$ inventree --config config.yaml part --list
Connecting... Connected.
[TABLE] PART : ['GET', 'CREATE', 'UPDATE', 'DELETE']

Get part using ID

$ inventree --config config.yaml part --op GET --id 145
Connecting... Connected.
[TABLE/OP] PART : GET
RES-000145-00 | RES SMD 100K OHM 1% 1/16W 0402 | A

Get part using name

$ inventree --config config.yaml part --op GET --name 'RES SMD 100K OHM 1% 1/16W 0402'
Connecting... Connected.
[TABLE/OP] PART : GET
RES-000145-00 | RES SMD 100K OHM 1% 1/16W 0402 | A

@eeintech eeintech changed the title Started proof of concept for wrapper class and CLI Wrapper class and CLI Jul 21, 2021
@eeintech eeintech marked this pull request as draft July 21, 2021 19:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant