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
9 changes: 8 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,14 @@ on:

jobs:
check:
runs-on: windows-latest
strategy:
matrix:
os:
- windows-latest
- ubuntu-latest

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
Expand Down
27 changes: 25 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: release

on:
push:
tags: ["v*"]
Expand All @@ -17,10 +18,32 @@ jobs:
run: |
v="${GITHUB_REF_NAME#v}"
grep -q "^version = \"$v\"" Cargo.toml
- run: cargo build --release --locked
- uses: softprops/action-gh-release@v2
- name: Build
run: cargo build --release --locked
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
target/release/pogly.exe
target/release/pogly-cli.exe

release-linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Verify tag matches workspace version
shell: bash
run: |
v="${GITHUB_REF_NAME#v}"
grep -q "^version = \"$v\"" Cargo.toml
- name: Build
run: cargo build --release --locked
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
generate_release_notes: true
files: |
target/release/pogly
target/release/pogly-cli
40 changes: 33 additions & 7 deletions README.md

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first code block under the title lost its ``` fences and a line break got inserted inside "#82a5ff" (looks like an editor auto-format).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

%LOCALAPPDATA%\Pogly\cli\bin<version>\pogly-cli.exe is missing the backslash before <version>.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# pogly-cli

A Windows command-line tool for managing a [Pogly](https://pogly.gg) overlay through its HTTP API — and an open-source reference for building your own API integrations.
A Windows and Linux command-line tool for managing a [Pogly](https://pogly.gg) overlay through its HTTP API — and an open-source reference for building your own API integrations.

```
pogly elements add text --text "New follower!" --size 64 --color "#82a5ff" --x 200 --y 150
Expand All @@ -21,23 +21,49 @@ iwr https://cli.pogly.gg -useb | iex

This downloads the [latest release](https://github.com/PoglyApp/pogly-cli/releases), installs it to `%LOCALAPPDATA%\Pogly\cli`, and adds it to your `PATH`. The script it runs is [install.ps1](install.ps1) if you'd rather read it first.

Quick install (Bash):

```bash
curl -fsSL https://cli.pogly.gg/install.sh | bash
```

This downloads the [latest release](https://github.com/PoglyApp/pogly-cli/releases), installs it to `~/.local/share/Pogly/cli` (or `$XDG_DATA_HOME/Pogly/cli`), and adds it to your `PATH` via `~/.bashrc` or `~/.zshrc`. The script it runs is [install.sh](install.sh) if you'd rather read it first.

### Manual install

1. Download `pogly.exe` and `pogly-cli.exe` from the [latest release](https://github.com/PoglyApp/pogly-cli/releases).
1. Download `pogly` and `pogly-cli` (Linux) or `pogly.exe` and `pogly-cli.exe` (Windows) from the [latest release](https://github.com/PoglyApp/pogly-cli/releases).
2. Place them like this (`<version>` is the release version, e.g. `0.1.0`):

**Windows:**
```
%LOCALAPPDATA%\Pogly\cli\pogly.exe
%LOCALAPPDATA%\Pogly\cli\bin\<version>\pogly-cli.exe
```
3. Add `%LOCALAPPDATA%\Pogly\cli` to your `PATH`.

**Linux:**
```
~/.local/share/Pogly/cli/pogly
~/.local/share/Pogly/cli/bin/<version>/pogly-cli
```
(or under `$XDG_DATA_HOME/Pogly/cli` if that's set)

3. On Linux, `chmod +x` both binaries.
4. Write the version string (no trailing newline) to `version` next to `pogly`/`pogly.exe`.
5. Add that directory to your `PATH`.

### Uninstall

Run [uninstall.ps1](uninstall.ps1) — it removes the binaries, version store, and PATH entry. Your overlay profiles are kept unless you pass `-PurgeConfig`.
**Windows:** run [uninstall.ps1](uninstall.ps1) — it removes the binaries, version store, and PATH entry. Your overlay profiles are kept unless you pass `-PurgeConfig`.

**Linux:**
```bash
curl -fsSL https://cli.pogly.gg/uninstall.sh | bash
```
Or run [uninstall.sh](uninstall.sh) directly if you already have it locally. It removes the binaries, version store, and PATH entry; overlay profiles are kept unless you pass `--purge-config`.

### Version management

`pogly.exe` is a small launcher that runs the selected `pogly-cli.exe`, so multiple versions can live side by side:
`pogly` (`pogly.exe` on Windows) is a small launcher that runs the selected `pogly-cli` (`pogly-cli.exe` on Windows), so multiple versions can live side by side:

```
pogly version # show the current version
Expand Down Expand Up @@ -70,7 +96,7 @@ pogly elements delete 42
| --- | --- |
| `ping` | Check that the overlay API is reachable (no token needed) |
| `whoami` | Show the token's label, identity, and permissions |
| `overlay list\|add\|update\|remove\|set-default` | Manage overlay profiles (stored in `%APPDATA%\Pogly\cli\config.toml`) |
| `overlay list\|add\|update\|remove\|set-default` | Manage overlay profiles (stored in `%APPDATA%\Pogly\cli\config.toml` on Windows, `~/.config/Pogly/cli/config.toml` on Linux) |
| `elements list\|add <type>\|update\|delete` | Manage elements; `add` has `text`, `image`, `widget`, and `media` subcommands |
| `elementdata list\|add\|update\|delete` | Manage element data assets |
| `layouts list\|add\|duplicate\|rename\|delete\|set-active` | Manage layouts; `set-active` switches the live scene |
Expand All @@ -91,7 +117,7 @@ The [examples/](examples/) folder shows how to hook the CLI into your stream: St
cargo build --release
```

Produces `target\release\pogly-cli.exe` (the CLI) and `target\release\pogly.exe` (the launcher). Run the CLI directly during development: `cargo run -p pogly-cli -- <args>`.
On Windows this produces `target\release\pogly-cli.exe` (the CLI) and `target\release\pogly.exe` (the launcher). On Linux it produces `target/release/pogly-cli` and `target/release/pogly`. Run the CLI directly during development: `cargo run -p pogly-cli -- <args>`.

To test `version upgrade` against a fork, set `POGLY_RELEASES_REPO=<owner>/<repo>`.

Expand Down
53 changes: 47 additions & 6 deletions crates/cli/src/paths.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,58 @@
use std::path::PathBuf;

fn env_dir(var: &str) -> PathBuf {
std::env::var_os(var)
#[cfg(windows)]
fn config_base_dir() -> PathBuf {
std::env::var_os("APPDATA")
.map(PathBuf::from)
.unwrap_or_else(std::env::temp_dir)
.unwrap_or_else(|| {
std::env::var_os("USERPROFILE")
.map(PathBuf::from)
.unwrap_or_else(std::env::temp_dir)
})
}

#[cfg(not(windows))]
fn config_base_dir() -> PathBuf {
std::env::var_os("XDG_CONFIG_HOME")
.map(PathBuf::from)
.unwrap_or_else(|| {
std::env::var_os("HOME")
.map(PathBuf::from)
.unwrap_or_else(std::env::temp_dir)
.join(".config")
})
}

#[cfg(windows)]
fn local_base_dir() -> PathBuf {
std::env::var_os("LOCALAPPDATA")
.map(PathBuf::from)
.unwrap_or_else(|| {
std::env::var_os("USERPROFILE")
.map(PathBuf::from)
.unwrap_or_else(std::env::temp_dir)
})
}

#[cfg(not(windows))]
fn local_base_dir() -> PathBuf {
std::env::var_os("XDG_DATA_HOME")
.map(PathBuf::from)
.unwrap_or_else(|| {
std::env::var_os("HOME")
.map(PathBuf::from)
.unwrap_or_else(std::env::temp_dir)
.join(".local")
.join("share")
})
}

pub fn config_dir() -> PathBuf {
env_dir("APPDATA").join("Pogly").join("cli")
config_base_dir().join("Pogly").join("cli")
}

pub fn local_dir() -> PathBuf {
env_dir("LOCALAPPDATA").join("Pogly").join("cli")
local_base_dir().join("Pogly").join("cli")
}

pub fn config_file() -> PathBuf {
Expand All @@ -31,5 +72,5 @@ pub fn bin_dir() -> PathBuf {
}

pub fn launcher_path() -> PathBuf {
local_dir().join("pogly.exe")
local_dir().join(if cfg!(windows) { "pogly.exe" } else { "pogly" })
}
65 changes: 56 additions & 9 deletions crates/cli/src/versionstore.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,34 @@
use std::time::Duration;

use anyhow::{bail, Context, Result};
use anyhow::{Context, Result};
use serde_json::Value;
use ureq::Agent;

use crate::paths;

fn cli_binary_name() -> &'static str {
if cfg!(windows) {
"pogly-cli.exe"
} else {
"pogly-cli"
}
}

fn launcher_binary_name() -> &'static str {
if cfg!(windows) {
"pogly.exe"
} else {
"pogly"
}
}

pub fn installed_versions() -> Vec<String> {
let binary_name = cli_binary_name();
let mut versions: Vec<String> = std::fs::read_dir(paths::bin_dir())
.map(|entries| {
entries
.flatten()
.filter(|e| e.path().join("pogly-cli.exe").is_file())
.filter(|e| e.path().join(binary_name).is_file())
.filter_map(|e| e.file_name().into_string().ok())
.collect()
})
Expand Down Expand Up @@ -70,14 +87,24 @@ fn download(url: &str) -> Result<Vec<u8>> {
}

pub fn install_version(version: &str, release: &Value) -> Result<()> {
let url = asset_url(release, "pogly-cli.exe").context("release has no pogly-cli.exe asset")?;
let binary_name = cli_binary_name();
let url = asset_url(release, binary_name)
.with_context(|| format!("release has no {binary_name} asset"))?;
let dir = paths::bin_dir().join(version);
std::fs::create_dir_all(&dir)?;
let target = dir.join("pogly-cli.exe");
let tmp = dir.join("pogly-cli.exe.tmp");
let target = dir.join(binary_name);
let tmp = dir.join(format!("{binary_name}.tmp"));
std::fs::write(&tmp, download(url)?)?;
std::fs::rename(&tmp, &target)
.with_context(|| format!("failed to install {}", target.display()))?;
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;

let mut permissions = std::fs::metadata(&target)?.permissions();
permissions.set_mode(0o755);
std::fs::set_permissions(&target, permissions)?;
}
Ok(())
}

Expand All @@ -89,16 +116,36 @@ pub fn replace_launcher(release: &Value) -> Result<()> {
if !path.is_file() {
return Ok(());
}
let Some(url) = asset_url(release, "pogly.exe") else {
let launcher_name = launcher_binary_name();
let Some(url) = asset_url(release, launcher_name) else {
return Ok(());
};
let bytes = download(url)?;
let old = paths::local_dir().join("pogly.exe.old");
let old = paths::local_dir().join(if cfg!(windows) {
"pogly.exe.old"
} else {
"pogly.old"
});
let tmp = paths::local_dir().join(if cfg!(windows) {
"pogly.exe.tmp"
} else {
"pogly.tmp"
});
let _ = std::fs::remove_file(&old);
let _ = std::fs::remove_file(&tmp);
std::fs::write(&tmp, bytes).context("failed to write new launcher")?;
#[cfg(unix)]
{
use std::os::unix::fs::PermissionsExt;

let mut permissions = std::fs::metadata(&tmp)?.permissions();
permissions.set_mode(0o755);
std::fs::set_permissions(&tmp, permissions)?;
}
std::fs::rename(&path, &old).context("failed to move the current launcher aside")?;
if let Err(e) = std::fs::write(&path, bytes) {
if let Err(e) = std::fs::rename(&tmp, &path) {
let _ = std::fs::rename(&old, &path);
bail!("failed to write new launcher: {e}");
return Err(e).context("failed to install new launcher");
}
Ok(())
}
Loading
Loading