mtd-cli is a command line client for Linux (other Unices should not be hard to support) to interface with the UK’s HMRC Make Tax Digital API
It makes use of libmtdac
mtd-cli is primarily developed under Linux but it also builds and runs under FreeBSD.
Once you have the above library built and installed, building this is as simple as
$ make
$ gmake
or if you don’t have GCC installed
$ gmake CC=clang
It’s ready to use straight away, you can place the binary anywhere you like or just run it in place
$ src/mtd-cli
It has a fairly straightforward interface, essentially
mtd-cli init|init-creds|init-oauth|init-nino|bd|biss|bsas|ical|id|ie|iei|ilos|ipi|isb|isi|ob|pb|saa|saass|said|seb|vat|test_cu|test_fph|test_sa
The first argument specifies the API to interface with
- init is for doing an initial setup, creating the JSON config files. This runs the equivalent of; init-creds, init-oauth & init-nino.
- init-creds is for regenerating the creds.json file.
- init-oauth is for doing a reauthorisation.
- init-nino is for storing the National Insurance Number in the nino.json file.
Each of the above init functions (except init-nino) takes an argument of itsa or itsa-assist or vat depending on which API is to be initialised.
See libmtdac
Currently there are two environment variables that can bet set to control behaviour
This can be used to override the default log level (MTD_OPT_LOG_ERR).
Currently recognised values are; debug & info
This can take two extra optional parameters; a file path and an fopen(2) mode.
E.g.
$ MTD_CLI_OPT_LOG_LEVEL=debug:/tmp/mtd-cli.log mtd-cli ...
and
$ MTD_CLI_OPT_LOG_LEVEL=debug:/tmp/mtd-cli.log+a mtd-cli ...
The first will cause all log messages (except MTD_LOG_ERROR) to be written to the file /tmp/mtd-cli.log.
The second will do the above but will append messages to the file (creating it if it doesn't exist).
This of course does mean that the file name should not contain either a
:
or a +
.
This can be used to disable the sending of ‘Fraud Prevention Headers’, set it to
true or 1
This can be used to set extra HTTP headers to be sent.
Currently only one header is supported which should be sufficient for setting the Gov-Test-Scenario Test API header. e.g
$ MTD_CLI_HDRS="Gov-Test-Scenario: NO_SUBMISSIONS_EXIST" mtd-cli sa cr-intent-to-crystallise 2018-19
This is licensed under the GNU General Public License (GPL) version 2
See COPYING in the repository root for details.
See CodingStyle.rst & Contributing.rst
Andrew Clayton <[email protected]>