Skip to content

Commit 8f87f1c

Browse files
committed
fix windows build and add command help text
1 parent 40a066c commit 8f87f1c

3 files changed

Lines changed: 39 additions & 24 deletions

File tree

coman/src/cli.rs

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ use crate::{
1010

1111
#[derive(Subcommand, Debug)]
1212
pub enum CliCommands {
13+
#[clap(about = "Show version and config file locations")]
1314
Version,
15+
#[clap(about = "Subcommands related to CSCS")]
1416
Cscs {
1517
#[command(subcommand)]
1618
command: CscsCommands,
@@ -28,36 +30,37 @@ pub enum CliCommands {
2830

2931
#[derive(Subcommand, Debug)]
3032
pub enum CscsCommands {
33+
#[clap(about = "Log in to CSCS")]
3134
Login,
32-
#[clap(alias("j"))]
35+
#[clap(alias("j"), about = "Job subcommands [aliases: j]")]
3336
Job {
3437
#[command(subcommand)]
3538
command: CscsJobCommands,
3639
},
37-
#[clap(alias("f"))]
40+
#[clap(alias("f"), about = "File management subcommands [aliases: f]")]
3841
File {
3942
#[command(subcommand)]
4043
command: CscsFileCommands,
4144
},
42-
#[clap(alias("s"))]
45+
#[clap(
46+
alias("s"),
47+
about = "Subcommands for managing for interacting with the compute system config (e.g. 'daint') [aliases: s]"
48+
)]
4349
System {
4450
#[command(subcommand)]
4551
command: CscsSystemCommands,
4652
},
4753
}
4854
#[derive(Subcommand, Debug)]
4955
pub enum CscsJobCommands {
50-
#[clap(alias("ls"))]
56+
#[clap(alias("ls"), about = "List all jobs [aliases: ls]")]
5157
List,
52-
#[clap(alias("g"))]
53-
Get {
54-
job_id: i64,
55-
},
56-
Log {
57-
job_id: i64,
58-
},
58+
#[clap(alias("g"), about = "Get metadata for a specific job [aliases: g]")]
59+
Get { job_id: i64 },
60+
#[clap(about = "Get the stdout of a job")]
61+
Log { job_id: i64 },
5962

60-
#[clap(alias("s"))]
63+
#[clap(alias("s"), about = "Submit a new compute job [aliases: s]")]
6164
Submit {
6265
#[clap(short, long, help = "the path to the srun script file to use")]
6366
script_file: Option<PathBuf>,
@@ -74,24 +77,25 @@ pub enum CscsJobCommands {
7477
#[clap(trailing_var_arg = true, help = "The command to run in the container")]
7578
command: Option<Vec<String>>,
7679
},
77-
#[clap(alias("c"))]
78-
Cancel {
79-
job_id: i64,
80-
},
80+
#[clap(
81+
alias("c"),
82+
about = "Cancel a running job, fails if the job isn't running [aliases: c]"
83+
)]
84+
Cancel { job_id: i64 },
8185
}
8286

8387
#[derive(Subcommand, Debug)]
8488
pub enum CscsFileCommands {
85-
#[clap(alias("ls"))]
89+
#[clap(alias("ls"), about = "List folders and files in a remote path [aliases: ls]")]
8690
List { path: PathBuf },
87-
#[clap(alias("dl"))]
91+
#[clap(alias("dl"), about = "Download a remote file [aliases: dl]")]
8892
Download {
8993
#[clap(short, long, help = "account/project to use")]
9094
account: Option<String>,
9195
remote: PathBuf,
9296
local: PathBuf,
9397
},
94-
#[clap(alias("ul"))]
98+
#[clap(alias("ul"), about = "Upload a file to remote storage [aliases: ul]")]
9599
Upload {
96100
#[clap(short, long, help = "account/project to use")]
97101
account: Option<String>,
@@ -102,11 +106,11 @@ pub enum CscsFileCommands {
102106

103107
#[derive(Subcommand, Debug)]
104108
pub enum CscsSystemCommands {
105-
#[clap(alias("ls"), about = "List available compute systems")]
109+
#[clap(alias("ls"), about = "List available compute systems [aliases: ls]")]
106110
List,
107111
#[clap(
108112
alias("s"),
109-
about = "Set system to use (e.g. `daint`, see `coman cscs ls` for available systems)"
113+
about = "Set system to use (e.g. `daint`, see `coman cscs ls` for available systems) [aliases: s]"
110114
)]
111115
Set {
112116
#[clap(short, long, action, help = "set in global config instead of project-local one")]

coman/src/cscs/handlers.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
use std::{os::unix::fs::MetadataExt, path::PathBuf};
1+
#[cfg(target_family = "unix")]
2+
use std::os::unix::fs::MetadataExt;
3+
#[cfg(target_family = "windows")]
4+
use std::os::windows::fs::MetadataExt;
5+
use std::path::PathBuf;
26

37
use color_eyre::{Result, eyre::eyre};
48
use reqwest::Url;
@@ -313,7 +317,14 @@ pub async fn cscs_file_upload(
313317
let config = Config::new().unwrap();
314318

315319
let file_meta = std::fs::metadata(local.clone())?;
316-
if (file_meta.size() as usize) < CSCS_MAX_DIRECT_SIZE {
320+
321+
#[cfg(target_family = "unix")]
322+
let size = file_meta.size() as usize;
323+
324+
#[cfg(target_family = "windows")]
325+
let size = file_meta.file_size() as usize;
326+
327+
if size < CSCS_MAX_DIRECT_SIZE {
317328
// upload directly
318329
let contents = std::fs::read(local)?;
319330
api_client

firecrest_client/src/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! AUTO-GENERATED CODE - DO NOT EDIT!
1010
//!
1111
//! FirecREST
12-
//! Source: /tmp/.tmpNLmwEL.json
12+
//! Source: /tmp/.tmpJ9quLA.json
1313
//! Version: 2.4.1
1414
//! Generated by `oas3-gen v0.21.1`
1515
//!

0 commit comments

Comments
 (0)