Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add command line interface #14

Open
lognaturel opened this issue Sep 21, 2022 · 1 comment
Open

Add command line interface #14

lognaturel opened this issue Sep 21, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@lognaturel
Copy link
Member

Can be useful for setting up shell scripts or doing basic exploration.

See centralpy and Briefcase.

@lognaturel lognaturel added the enhancement New feature or request label Sep 21, 2022
@matthew-white
Copy link
Member

matthew-white commented May 8, 2023

I often send requests to the Central API from the command line. In the past, I've used curl to do so, but I've been finding pyODK very helpful for that purpose. The caching of the session token is very convenient, and the fact that configuration is file-based makes it easy to toggle between different servers.

I always do the same 5 or 10 things when I use curl with Central, so I thought I'd wrap those in a small Python script. I haven't tested much of the script, and I'm not very familiar with Python, but I thought I'd share it for discussion purposes: https://gist.github.com/matthew-white/3ece8de162c2ef5d974d5d2f6ed4ff23

Many of the script's CLI options are very generic (e.g., --header), but I also added some Central-specific features:

  • --extended option to easily request extended metadata
  • Specify request data using one of --json, --xml, and --file, which are the kinds of data that Central expects. --json and --xml can be combined with --file.
  • Headers like X-OpenRosa-Version and X-XlsForm-FormId-Fallback are added automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants