Skip to content

Commit

Permalink
Add Python bindings generation command (#1761)
Browse files Browse the repository at this point in the history
  • Loading branch information
overcat authored Nov 27, 2024
1 parent 97cf235 commit a11a924
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions FULL_HELP_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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



Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions cmd/soroban-cli/src/commands/contract/bindings.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod json;
pub mod python;
pub mod rust;
pub mod typescript;

Expand All @@ -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)]
Expand All @@ -24,6 +28,9 @@ pub enum Error {

#[error(transparent)]
Typescript(#[from] typescript::Error),

#[error(transparent)]
Python(#[from] python::Error),
}

impl Cmd {
Expand All @@ -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(())
}
Expand Down
19 changes: 19 additions & 0 deletions cmd/soroban-cli/src/commands/contract/bindings/python.rs
Original file line number Diff line number Diff line change
@@ -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)
}
}

0 comments on commit a11a924

Please sign in to comment.