any2nix_cli/lib.rs
1// SPDX-FileCopyrightText: 2026 Gabriel Santos de Souza <gabriel.santosdesouza@dcomp.ufs.br>
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#![doc(html_favicon_url = "https://zipline.gs-101.dev/u/DF6up7.ico")]
6#![doc(html_logo_url = "https://zipline.gs-101.dev/u/DZWGB0.svg")]
7//! This crate provides a command-line interface for translating different
8//! formats to [Nix](https://nixos.org).
9//!
10//! # Supported Formats
11//!
12//! See [any2nix::Format] for an enumeration of supported formats.
13//!
14//! Each format is gated behind its own [feature](https://doc.rust-lang.org/cargo/reference/features.html).
15//!
16//! The default feature enables all formats.
17
18use any2nix::Format;
19use clap::Parser;
20use clap_complete::Shell;
21
22/// Generator of the program's flags.
23#[derive(Parser, Debug)]
24#[command(about, name = "any2nix", version)]
25pub struct Cli {
26 /// Generate shell completions for the given shell.
27 #[arg(exclusive = true, long, value_enum)]
28 pub completions: Option<Shell>,
29
30 /// The format of the input data.
31 #[arg(long, required_unless_present_any = ["completions", "man"], short, value_enum)]
32 pub format: Option<Format>,
33
34 /// The input file to convert. If missing or "-", reads from stdin.
35 pub input: Option<String>,
36
37 /// Generate a manpage in roff format.
38 #[arg(exclusive = true, long)]
39 pub man: bool,
40}