Compare commits
7 Commits
d4ca9e7542
...
v1.1.4
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80d2e7fd71 | ||
|
|
03e1311e90 | ||
|
|
a93f3ad9f6 | ||
|
|
b0407d6519 | ||
|
|
c484f2deb8 | ||
|
|
958a729880 | ||
|
|
8c6ed94850 |
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -1203,7 +1203,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ostiary"
|
name = "ostiary"
|
||||||
version = "1.1.2"
|
version = "1.1.4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"base64",
|
"base64",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "ostiary"
|
name = "ostiary"
|
||||||
version = "1.1.2"
|
version = "1.1.4"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -108,4 +108,8 @@ fi
|
|||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
ok "Launching ${BINARY}..."
|
ok "Launching ${BINARY}..."
|
||||||
exec "$INSTALL_DIR/$BINARY"
|
if { true </dev/tty; } 2>/dev/null; then
|
||||||
|
"$INSTALL_DIR/$BINARY"
|
||||||
|
else
|
||||||
|
ok "Run: $BINARY"
|
||||||
|
fi
|
||||||
|
|||||||
28
src/main.rs
28
src/main.rs
@@ -12,6 +12,8 @@ mod updater;
|
|||||||
|
|
||||||
use std::io;
|
use std::io;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
#[cfg(unix)]
|
||||||
|
use libc;
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{DisableMouseCapture, EnableMouseCapture},
|
event::{DisableMouseCapture, EnableMouseCapture},
|
||||||
execute,
|
execute,
|
||||||
@@ -29,6 +31,18 @@ async fn main() -> Result<()> {
|
|||||||
config::Config::create_with_endpoint(&url, &name)?
|
config::Config::create_with_endpoint(&url, &name)?
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Before initializing the TUI, ensure our process group is the terminal's
|
||||||
|
// foreground group. When launched from a non-interactive install script on
|
||||||
|
// macOS, the parent shell may not have granted terminal ownership, causing
|
||||||
|
// crossterm's kqueue-based input reader to fail silently.
|
||||||
|
#[cfg(unix)]
|
||||||
|
{
|
||||||
|
use std::os::unix::io::AsRawFd;
|
||||||
|
if let Ok(tty) = std::fs::File::open("/dev/tty") {
|
||||||
|
unsafe { libc::tcsetpgrp(tty.as_raw_fd(), libc::getpgrp()); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
enable_raw_mode()?;
|
enable_raw_mode()?;
|
||||||
let mut stdout = io::stdout();
|
let mut stdout = io::stdout();
|
||||||
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
|
execute!(stdout, EnterAlternateScreen, EnableMouseCapture)?;
|
||||||
@@ -172,17 +186,15 @@ async fn run_exec(
|
|||||||
fn prompt_first_endpoint() -> Result<(String, String)> {
|
fn prompt_first_endpoint() -> Result<(String, String)> {
|
||||||
use std::io::{BufRead, BufReader, Write};
|
use std::io::{BufRead, BufReader, Write};
|
||||||
|
|
||||||
// Open /dev/tty directly so input works even when launched via `curl | bash`
|
// Open /dev/tty read-only for keyboard input so the wizard works even when
|
||||||
// (where stdin is the pipe carrying the script, not the keyboard).
|
// stdin is a pipe (e.g. `curl | bash`). Writing goes through stdout so we
|
||||||
let tty = std::fs::OpenOptions::new()
|
// don't touch the terminal's write-side state before crossterm takes over.
|
||||||
.read(true)
|
let tty_in = std::fs::File::open("/dev/tty")
|
||||||
.write(true)
|
|
||||||
.open("/dev/tty")
|
|
||||||
.map_err(|e| anyhow::anyhow!(
|
.map_err(|e| anyhow::anyhow!(
|
||||||
"Не удалось открыть терминал ({e}). Запустите ostiary напрямую."
|
"Не удалось открыть терминал ({e}). Запустите ostiary напрямую."
|
||||||
))?;
|
))?;
|
||||||
let mut out = tty.try_clone()?;
|
let mut reader = BufReader::new(tty_in);
|
||||||
let mut reader = BufReader::new(tty);
|
let mut out = std::io::stdout();
|
||||||
|
|
||||||
writeln!(out)?;
|
writeln!(out)?;
|
||||||
writeln!(out, " ╔══════════════════════════════════╗")?;
|
writeln!(out, " ╔══════════════════════════════════╗")?;
|
||||||
|
|||||||
Reference in New Issue
Block a user