Skip to content
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
runner: windows-11-arm

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@v1
Expand All @@ -45,7 +45,7 @@ jobs:
targets: ${{ matrix.target }}

- name: Cache cargo
uses: Swatinem/rust-cache@v2.8.2
uses: Swatinem/rust-cache@v2.9.1
with:
key: ${{ matrix.target }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@v1
Expand All @@ -47,7 +47,7 @@ jobs:
targets: ${{ matrix.target }}

- name: Cache cargo
uses: Swatinem/rust-cache@v2.8.2
uses: Swatinem/rust-cache@v2.9.1
with:
key: ${{ matrix.target }}
shared-key: release
Expand Down Expand Up @@ -120,7 +120,7 @@ jobs:
echo "PACKAGE_PATH=release/$out" >> $GITHUB_ENV

- name: Upload artifact
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v7
with:
name: ${{ matrix.target }}
path: ${{ env.PACKAGE_PATH }}
Expand All @@ -134,7 +134,7 @@ jobs:

steps:
- name: Download artifacts
uses: actions/download-artifact@v4
uses: actions/download-artifact@v7
with:
path: artifacts

Expand Down
117 changes: 59 additions & 58 deletions src/commands/cli.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use clap::{Parser, Subcommand, ValueEnum};
use clap::{Args, Parser, Subcommand, ValueEnum};
use std::path::PathBuf;

#[derive(Parser, Debug)]
Expand All @@ -23,72 +23,73 @@ pub struct Cli {
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Convert subscription configuration
Convert {
/// Input sources: <path|url>?type=clash&name=...&flag=... (type required in query)
#[arg(long = "source", value_name = "SOURCE")]
sources: Vec<String>,

/// Template file path
#[arg(short, long, value_name = "PATH")]
template: Option<PathBuf>,

/// Output file path
#[arg(short, long, value_name = "PATH")]
output: Option<PathBuf>,

/// Target output protocol (sing-box, clash, v2ray).
/// The output format is determined by the protocol:
/// - sing-box: JSON only
/// - clash: YAML only
/// - v2ray: JSON only
#[arg(long = "output-protocol", value_name = "PROTOCOL")]
output_protocol: Option<String>,

/// Log level
#[arg(short, long, value_enum, default_value_t = LogLevel::Info)]
log_level: LogLevel,

/// Whether to show detailed information
#[arg(short, long)]
verbose: bool,

/// HTTP request timeout in seconds
#[arg(long, value_name = "SECONDS")]
timeout: Option<u64>,
},
Convert(ConvertArgs),

/// Validate configuration file
Validate {
/// Configuration file path to validate
#[arg(value_name = "PATH")]
file: PathBuf,

/// Target protocol (sing-box, clash, v2ray). Default: sing-box
#[arg(short, long, value_name = "PROTOCOL", default_value = "singbox")]
protocol: String,
},
Validate(ValidateArgs),

/// Generate default template
Template {
/// Output path
#[arg(short, long, value_name = "PATH")]
output: Option<PathBuf>,

/// Target protocol (sing-box, clash, v2ray). Default: sing-box
#[arg(short, long, value_name = "PROTOCOL", default_value = "singbox")]
protocol: String,
},
Template(TemplateArgs),

/// Display version information
Version,
}

#[derive(ValueEnum, Clone, Debug)]
pub enum OutputFormat {
/// JSON format
Json,
/// YAML format
Yaml,
#[derive(Args, Debug)]
pub struct ConvertArgs {
/// Input sources: <path|url>?type=clash&name=...&flag=... (type required in query)
#[arg(long = "source", value_name = "SOURCE")]
pub sources: Vec<String>,

/// Template file path
#[arg(short, long, value_name = "PATH")]
pub template: Option<PathBuf>,

/// Output file path
#[arg(short, long, value_name = "PATH")]
pub output: Option<PathBuf>,

/// Target output protocol (sing-box, clash, v2ray).
/// The output format is determined by the protocol:
/// - sing-box: JSON only
/// - clash: YAML only
/// - v2ray: JSON only
#[arg(long = "output-protocol", value_name = "PROTOCOL")]
pub output_protocol: Option<String>,

/// Log level
#[arg(short, long, value_enum, default_value_t = LogLevel::Info)]
pub log_level: LogLevel,

/// Whether to show detailed information
#[arg(short, long)]
pub verbose: bool,

/// HTTP request timeout in seconds
#[arg(long, value_name = "SECONDS")]
pub timeout: Option<u64>,
}

#[derive(Args, Debug)]
pub struct ValidateArgs {
/// Configuration file path to validate
#[arg(value_name = "PATH")]
pub file: PathBuf,

/// Target protocol (sing-box, clash, v2ray). Default: sing-box
#[arg(short, long, value_name = "PROTOCOL", default_value = "singbox")]
pub protocol: String,
}

#[derive(Args, Debug)]
pub struct TemplateArgs {
/// Output path
#[arg(short, long, value_name = "PATH")]
pub output: Option<PathBuf>,

/// Target protocol (sing-box, clash, v2ray). Default: sing-box
#[arg(short, long, value_name = "PROTOCOL", default_value = "singbox")]
pub protocol: String,
}

#[derive(ValueEnum, Clone, Copy, Debug)]
Expand Down
Loading