Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/check-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ jobs:
php-version: '8.4'
coverage: none
tools: none
- name: Check all eight languages
- name: Check all nine languages
run: python scripts/check_examples.py

local-sotto:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ sotto.toml
**/build/
**/bin/
**/obj/
**/target/
**/Cargo.lock
**/__pycache__/
*.class
node_modules/
Expand Down
3 changes: 2 additions & 1 deletion csharp/Demo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net10.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<RollForward>LatestMajor</RollForward>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion csharp/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# C# demo

Requires **.NET 10 SDK**. Follow the [root quick start](../README.md#quick-start-with-python)
Requires **.NET 8 SDK or newer**. Follow the [root quick start](../README.md#quick-start-with-python)
to install Sotto, run `sotto init` once, and set `DEMO_SECRET`.

Run from the **repository root**:
Expand Down
2 changes: 1 addition & 1 deletion javascript/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# JavaScript demo

Requires **Node.js 24 LTS**. Follow the [root quick start](../README.md#quick-start-with-python)
Requires **Node.js 18 or newer** (24 LTS in CI). Follow the [root quick start](../README.md#quick-start-with-python)
to install Sotto, run `sotto init` once, and set `DEMO_SECRET`.

Run from the **repository root**:
Expand Down
5 changes: 5 additions & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[package]
name = "demo"
version = "0.1.0"
edition = "2021"
publish = false
25 changes: 25 additions & 0 deletions rust/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Rust demo

Requires **Rust and Cargo** (stable toolchain). Follow the [root quick start](../README.md#quick-start-with-python)
to install Sotto, run `sotto init` once, and set `DEMO_SECRET`.

Run from the **repository root**:

```sh
sotto run -- cargo run --quiet --manifest-path rust/Cargo.toml
```

Cargo compiles and runs this single binary crate using only the Rust standard library. No external crates are needed.

Expected output:

```text
Sotto demo: secret loaded successfully.
```

The program reads `DEMO_SECRET` through the standard environment API and never
prints its value. A missing or empty value produces a helpful stderr message
and exit code `1`; any non empty value returns `0`.

To see the failure, run the same program command without `sotto run --` while
`DEMO_SECRET` is unset in your shell.
12 changes: 12 additions & 0 deletions rust/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
use std::env;
use std::process;

fn main() {
let has_secret = env::var_os("DEMO_SECRET").is_some_and(|value| !value.is_empty());
if !has_secret {
eprintln!("DEMO_SECRET is missing or empty. Set it with `sotto set DEMO_SECRET`, then run this demo with `sotto run -- <command>`.");
process::exit(1);
}

println!("Sotto demo: secret loaded successfully.");
}
5 changes: 4 additions & 1 deletion scripts/check_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@
"csharp": ["dotnet", "run", "--no-build", "--no-restore", "--project", "csharp/Demo.csproj"],
"php": ["php", "php/main.php"],
"go": ["go", "run", "go/main.go"],
"rust": [str(ROOT / "rust/target/debug" / ("demo.exe" if os.name == "nt" else "demo"))],
"cpp": [str(ROOT / "cpp/build" / ("demo.exe" if os.name == "nt" else "demo"))],
}


def main():
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("languages", nargs="*", help="Default: all eight languages")
parser.add_argument("languages", nargs="*", help="Default: all nine languages")
args = parser.parse_args()
languages = args.languages or list(COMMANDS)
for language in languages:
Expand All @@ -32,6 +33,8 @@ def main():

if "csharp" in languages:
subprocess.run(["dotnet", "build", "csharp/Demo.csproj", "--nologo"], cwd=ROOT, check=True)
if "rust" in languages:
subprocess.run(["cargo", "build", "--quiet", "--manifest-path", "rust/Cargo.toml"], cwd=ROOT, check=True)
if "cpp" in languages:
subprocess.run(["cmake", "-S", "cpp", "-B", "cpp/build"], cwd=ROOT, check=True)
subprocess.run(["cmake", "--build", "cpp/build", "--config", "Release"], cwd=ROOT, check=True)
Expand Down
2 changes: 1 addition & 1 deletion typescript/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TypeScript demo

Requires **Node.js 24.12 or newer**. Follow the [root quick start](../README.md#quick-start-with-python)
Requires **Node.js 22.18 or newer** (24 LTS in CI). Follow the [root quick start](../README.md#quick-start-with-python)
to install Sotto, run `sotto init` once, and set `DEMO_SECRET`.

Run from the **repository root**:
Expand Down
Loading