Skip to content

Commit

Permalink
Session id is u64. // Parse hex display version of session id for kil…
Browse files Browse the repository at this point in the history
…l --id command.
  • Loading branch information
meowjesty committed Feb 19, 2024
1 parent 21d3ad3 commit c308685
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions mirrord/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,8 +238,8 @@ pub(crate) enum SessionCommand {
/// Kills the session specified by `id`.
Kill {
/// Id of the session.
#[arg(short, long)]
id: u32,
#[arg(short, long, value_parser=hex_id)]
id: u64,
},
/// Kills all operator sessions.
KillAll,
Expand All @@ -249,6 +249,14 @@ pub(crate) enum SessionCommand {
RetainActive,
}

/// Parses the operator session id from hex (without `0x` prefix) into `u64`. It also accepts the
/// non-hex version of the id.
fn hex_id(raw: &str) -> Result<u64, String> {
raw.parse::<u64>()
.or_else(|_| u64::from_str_radix(raw, 16))
.map_err(|fail| format!("Failed parsing hex id value with {fail}!"))
}

#[derive(ValueEnum, Clone, Debug)]
pub enum Format {
Json,
Expand Down
2 changes: 1 addition & 1 deletion mirrord/cli/src/operator/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub(super) async fn operator_session_kill_all() -> Result<()> {

/// `mirrord operator session kill {id}`: kills the operator session specified by `id`.
#[tracing::instrument(level = "trace", ret)]
pub(super) async fn operator_session_kill_one(id: u32) -> Result<()> {
pub(super) async fn operator_session_kill_one(id: u64) -> Result<()> {
let (progress, api, sub_progress) = operator_session_prepare().await?;

sub_progress.print("killing session with id {session_id}");
Expand Down

0 comments on commit c308685

Please sign in to comment.