Skip to content
Open
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
17 changes: 17 additions & 0 deletions src/cli/cmd/session/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ pub struct Input {
/// Start the session and show the logs until it ends or the user cancels with Ctrl-C.
#[arg(long, default_value_t = false)]
pub wait: bool,
/// Open the session in the browser.
#[arg(long, default_value_t = false)]
pub open: bool,
}

#[derive(Debug, Snafu)]
Expand All @@ -49,6 +52,20 @@ impl Input {
.await
.context(HttpClientSnafu)?;

if self.open
&& let Err(e) = open::that(result.effective_url().as_str())
{
ctx.write_result(&SimpleMessage {
message: format!(
"Couldn't open browser, please navigate to {}: {}",
result.effective_url(),
e
),
})
.await
.context(WriteResultSnafu)?;
};

if self.wait {
ctx.write_result(&SimpleMessage {
message: format!("Started session {}. Waiting for logs...", result.name,),
Expand Down
12 changes: 11 additions & 1 deletion src/httpclient/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ where
for r in data {
let started = r.started.format();
let status = r.status.state.to_str();
let data = vec![&r.name, &r.project_id, status, &started, &r.url];
let url = r.effective_url();
let data = vec![&r.name, &r.project_id, status, &started, &url];
builder.push_record(data);
}
builder.insert_record(0, vec!["Name", "Project Id", "Status", "Started", "Url"]);
Expand Down Expand Up @@ -279,6 +280,15 @@ pub struct SessionStartResponse {
pub started: Timestamp,
pub session_type: SessionMode,
pub url: String,
pub external_url: Option<String>,
}
impl SessionStartResponse {
pub fn effective_url(&self) -> String {
match &self.external_url {
Some(u) => u.clone(),
None => self.url.clone(),
}
}
}

impl fmt::Display for SessionStartResponse {
Expand Down
Loading