Skip to content

Add pygisceclient CLI for scripting and AI agent use#27

Open
Copilot wants to merge 4 commits intomainfrom
copilot/add-cli-command-line-util
Open

Add pygisceclient CLI for scripting and AI agent use#27
Copilot wants to merge 4 commits intomainfrom
copilot/add-cli-command-line-util

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

Adds a command-line interface to the package so ERP methods can be called from shell scripts and AI agent skills without writing Python.

Changes

  • gisce/cli.py — argparse-based CLI; connects via the existing connect() function, calls a model method, and prints the result as JSON to stdout. Errors go to stderr with a non-zero exit code.
  • setup.py — registers pygisceclient as a console_scripts entry point.
  • tests/test_cli.py — 18 tests covering argument parsing, auth variants, JSON validation, error paths, and successful calls.
  • README.md — CLI usage section with options table and examples.

Usage

# Search with user/password auth
pygisceclient \
  --url https+xmlrpc://erp.example.com \
  --database mydb \
  --user admin --password secret \
  --model res.users \
  --method search \
  --args '[[["active", "=", true]]]'

# Read specific fields with a token
pygisceclient \
  --url https+restapi://erp.example.com \
  --database mydb \
  --token myapitoken \
  --model res.users \
  --method read \
  --args '[[1, 2, 3]]' \
  --kwargs '{"fields": ["name", "login"]}'

Result is printed as indented JSON to stdout, making it straightforward to pipe into jq or consume in agent tool calls.

Copilot AI linked an issue Apr 3, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/gisce/py-gisce-client/sessions/4db6edc5-ddfb-4827-85c2-a757ffb9fbe7

Co-authored-by: ecarreras <294235+ecarreras@users.noreply.github.com>
Copilot AI changed the title [WIP] Add command line util for ai agents skills Add pygisceclient CLI for scripting and AI agent use Apr 3, 2026
Copilot AI requested a review from ecarreras April 3, 2026 03:33
@ecarreras
Copy link
Copy Markdown
Member

@copilot arregla els tests per python2

Run pytest tests/ -v --tb=short
============================= test session starts ==============================
platform linux2 -- Python 2.7.18, pytest-4.6.11, py-1.11.0, pluggy-0.13.1 -- /usr/local/bin/python
cachedir: .pytest_cache
rootdir: /__w/py-gisce-client/py-gisce-client
collecting ... collected 8 items / 1 errors / 7 selected

==================================== ERRORS ====================================
______________________ ERROR collecting tests/test_cli.py ______________________
ImportError while importing test module '/__w/py-gisce-client/py-gisce-client/tests/test_cli.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_cli.py:7: in <module>
    from unittest.mock import patch, MagicMock
E   ImportError: No module named mock
=============================== warnings summary ===============================
/usr/local/lib/python2.7/site-packages/responses/__init__.py:85
  /usr/local/lib/python2.7/site-packages/responses/__init__.py:85: DeprecationWarning: Support for Python 2.7 is being removed from the next release of responses. Pin your dependency to responses==0.17 or lower.
    DeprecationWarning,

-- Docs: https://docs.pytest.org/en/latest/warnings.html
!!!!!!!!!!!!!!!!!!! Interrupted: 1 errors during collection !!!!!!!!!!!!!!!!!!!!
===================== 1 warnings, 1 error in 0.23 seconds ======================

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 9, 2026

@copilot arregla els tests per python2

...

Fixed in a6b8129. Changed the mock import to use the same Python 2/3 compatible pattern as the existing tests:

try:
    from unittest.mock import patch, MagicMock
except ImportError:
    from mock import patch, MagicMock

Also added mock to requirements-dev.txt so it's available on Python 2.7.

@ecarreras ecarreras marked this pull request as ready for review April 9, 2026 08:51
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.

Add CLI

2 participants