Skip to content

feat: Add cqueue/cinfo -o to control the output format #228

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Feb 17, 2025
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
45 changes: 31 additions & 14 deletions internal/cacct/CmdArgParser.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,25 +112,42 @@ func init() {

RootCmd.Flags().StringVarP(&FlagFormat, "format", "o", "",
`Specify the output format.
Fields are identified by a percent sign (%) followed by a character.
Use a dot (.) and a number between % and the format character to specify a minimum width for the field.

Supported format identifiers:
%a: Account - Displays the account associated with the job.
%c: AllocCPUs - Displays the number of allocated CPUs, formatted to two decimal places.
%e: ExitCode - Displays the exit code of the job.
If the exit code is based on a specific base (e.g., kCraneExitCodeBase),
it formats as "0:<code>" or "<code>:0" based on the condition.
%j: JobID - Displays the ID of the job.
%n: Name - Displays the name of the job.
%P: Partition - Displays the partition associated with the job.
%t: State - Displays the state of the job.
Fields are identified by a percent sign (%) followed by a character or string.
Use a dot (.) and a number between % and the format character or string to specify a minimum width for the field.
Supported format identifiers or string, string case insensitive:
%a/%Account - Display the account associated with the job.
%c/%AllocCpus - Display the number of allocated CPUs, formatted to two decimal places.
%D/%ElapsedTime - Display the elapsed time from the start of the job.
%E/%EndTime - Display the end time of the job.
%e/%ExitCode - Display the exit code of the job.
If the exit code is based on a specific base (e.g., kCraneExitCodeBase),
it formats as "0:<code>" or "<code>:0" based on the condition.
%h/%Held - Display the hold status of the job.
%j/%JobID - Display the ID of the job.
%L/%NodeList - Display the list of nodes the job is running on.
%l/%TimeLimit - Display the time limit of the job.
%m/%MemPerNode - Display the requested mem per node of the job.
%N/%NodeNum - Display the node num of the job.
%n/%JobName - Display the name of the job.
%P/%Partition - Display the partition associated with the job.
%p/%Priority - Display the priority of the job.
%q/%Qos - Display the QoS of the job.
%R/%Reason - Display the reason of pending.
%r/%ReqNodes - Display the reqnodes of the job.
%S/%StartTime - Display the start time of the job.
%s/%SubmitTime - Display the submit time num of the job.
%t/%State - Display the state of the job.
%T/%JobType - Display the job type.
%U/%UserName - Display the username of the job.
%u/%Uid - Display the uid of the job.
%x/%ExcludeNodes - Display the excludenodes of the job.

Each format specifier can be modified with a width specifier (e.g., "%.5j").
Each format specifier or string can be modified with a width specifier (e.g., "%.5j").
If the width is specified, the field will be formatted to at least that width.
If the format is invalid or unrecognized, the program will terminate with an error message.

Example: --format "%.5j %.20n %t" would output the job's ID with a minimum width of 5,
Example: --format "%.5jobid %.20n %t" would output the job's ID with a minimum width of 5,
Name with a minimum width of 20, and the State.
`)
RootCmd.Flags().BoolVarP(&FlagFull, "full", "F", false, "Display full information (If not set, only display 30 characters per cell)")
Expand Down
Loading