From a11a924d310c1602e7b579377daa3e373010ac0e Mon Sep 17 00:00:00 2001 From: Jun Luo <4catcode@gmail.com> Date: Wed, 27 Nov 2024 22:54:01 +0800 Subject: [PATCH] Add Python bindings generation command (#1761) --- FULL_HELP_DOCS.md | 9 +++++++++ .../src/commands/contract/bindings.rs | 8 ++++++++ .../src/commands/contract/bindings/python.rs | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+) create mode 100644 cmd/soroban-cli/src/commands/contract/bindings/python.rs diff --git a/FULL_HELP_DOCS.md b/FULL_HELP_DOCS.md index 1ba366ac0..27fb7bead 100644 --- a/FULL_HELP_DOCS.md +++ b/FULL_HELP_DOCS.md @@ -258,6 +258,7 @@ Generate code client bindings for a contract * `json` — Generate Json Bindings * `rust` — Generate Rust bindings * `typescript` — Generate a TypeScript / JavaScript package +* `python` — Generate Python bindings @@ -306,6 +307,14 @@ Generate a TypeScript / JavaScript package +## `stellar contract bindings python` + +Generate Python bindings + +**Usage:** `stellar contract bindings python` + + + ## `stellar contract build` Build a contract from source diff --git a/cmd/soroban-cli/src/commands/contract/bindings.rs b/cmd/soroban-cli/src/commands/contract/bindings.rs index 1da946979..a91c966aa 100644 --- a/cmd/soroban-cli/src/commands/contract/bindings.rs +++ b/cmd/soroban-cli/src/commands/contract/bindings.rs @@ -1,4 +1,5 @@ pub mod json; +pub mod python; pub mod rust; pub mod typescript; @@ -12,6 +13,9 @@ pub enum Cmd { /// Generate a TypeScript / JavaScript package Typescript(typescript::Cmd), + + /// Generate Python bindings + Python(python::Cmd), } #[derive(thiserror::Error, Debug)] @@ -24,6 +28,9 @@ pub enum Error { #[error(transparent)] Typescript(#[from] typescript::Error), + + #[error(transparent)] + Python(#[from] python::Error), } impl Cmd { @@ -32,6 +39,7 @@ impl Cmd { Cmd::Json(json) => json.run()?, Cmd::Rust(rust) => rust.run()?, Cmd::Typescript(ts) => ts.run().await?, + Cmd::Python(python) => python.run()?, } Ok(()) } diff --git a/cmd/soroban-cli/src/commands/contract/bindings/python.rs b/cmd/soroban-cli/src/commands/contract/bindings/python.rs new file mode 100644 index 000000000..60a3e8dcb --- /dev/null +++ b/cmd/soroban-cli/src/commands/contract/bindings/python.rs @@ -0,0 +1,19 @@ +use std::fmt::Debug; + +use clap::Parser; + +#[derive(Parser, Debug, Clone)] +#[group(skip)] +pub struct Cmd {} + +#[derive(thiserror::Error, Debug)] +pub enum Error { + #[error("python binding generation is not implemented in the stellar-cli, but is available via the tool located here: https://github.com/lightsail-network/stellar-contract-bindings")] + NotImplemented, +} + +impl Cmd { + pub fn run(&self) -> Result<(), Error> { + Err(Error::NotImplemented) + } +}