1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
//! The `commands` module contains the subcommands for the `gh-workflow-parser` CLI.
/// The maximum Levenshtein distance for issues to be considered similar.
///
/// Determined in tests at the bottom of this file.
pub const LEVENSHTEIN_THRESHOLD: usize = 100;
use std::path::PathBuf;
use clap::*;
use clap::{Subcommand, ValueEnum};
use strum::{Display, EnumString};
pub mod create_issue_from_run;
pub mod locate_failure_log;
#[derive(Debug, Subcommand)]
pub enum Command {
/// Create a GitHub issue from a failed workflow run
CreateIssueFromRun {
/// The GitHub repository to parse
#[arg(long, value_hint = ValueHint::Url)]
repo: String,
/// The GitHub workflow run ID
#[arg(short = 'r', long)]
run_id: String,
/// The GitHub issue label
#[arg(short, long)]
label: String,
/// The kind of workflow (e.g. Yocto)
#[arg(short, long)]
kind: WorkflowKind,
/// Don't create the issue if a similar issue already exists
#[arg(short, long, default_value_t = true)]
no_duplicate: bool,
},
/// Locate the specific failure log in a failed build/test/other
LocateFailureLog {
/// The kind of workflow (e.g. Yocto)
#[arg(short, long)]
kind: BuildKind,
/// Log file to search for the failure log (e.g. log.txt or read from stdin)
/// File to operate on (if not provided, reads from stdin)
#[arg(short = 'f', long, value_hint = ValueHint::FilePath)]
input_file: Option<PathBuf>,
},
}
/// The kind of workflow (e.g. Yocto)
#[derive(ValueEnum, Display, Copy, Clone, Debug, PartialEq, Eq)]
pub enum WorkflowKind {
Yocto,
Other,
}
/// The kind of build (e.g. Yocto)
///
/// Could be extended to Python, Pytest, Vivado Synethesis, etc.
#[derive(ValueEnum, Display, EnumString, Copy, Clone, Debug, PartialEq, Eq)]
pub enum BuildKind {
Yocto,
Other,
}