-
Notifications
You must be signed in to change notification settings - Fork 118
Expand file tree
/
Copy pathmod.rs
More file actions
58 lines (47 loc) · 1.67 KB
/
mod.rs
File metadata and controls
58 lines (47 loc) · 1.67 KB
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
//! Module for generating recipes for Python (PyPI), R (CRAN), Perl (CPAN), Lua (LuaRocks) packages, or local Python projects
use clap::Parser;
mod cpan;
mod cran;
mod luarocks;
mod pypi;
mod pyproject;
mod serialize;
use cpan::{CpanOpts, generate_cpan_recipe};
use cran::{CranOpts, generate_r_recipe};
use luarocks::{LuarocksOpts, generate_luarocks_recipe};
use pypi::PyPIOpts;
use pyproject::{PyprojectOpts, generate_pyproject_recipe};
pub use serialize::write_recipe;
use self::pypi::generate_pypi_recipe;
/// The source of the package to generate a recipe for
#[derive(Debug, Clone, Parser)]
pub enum Source {
/// Generate a recipe for a Python package from PyPI
Pypi(PyPIOpts),
/// Generate a recipe for an R package from CRAN
Cran(CranOpts),
/// Generate a recipe for a Perl package from CPAN
Cpan(CpanOpts),
/// Generate a recipe for a Lua package from LuaRocks
Luarocks(LuarocksOpts),
/// Generate a recipe from a local pyproject.toml file
Pyproject(PyprojectOpts),
}
/// Options for generating a recipe
#[derive(Parser)]
pub struct GenerateRecipeOpts {
/// Type of package to generate a recipe for
#[clap(subcommand)]
pub source: Source,
}
/// Generate a recipe for a package
pub async fn generate_recipe(args: GenerateRecipeOpts) -> miette::Result<()> {
match args.source {
Source::Pypi(opts) => generate_pypi_recipe(&opts).await?,
Source::Cran(opts) => generate_r_recipe(&opts).await?,
Source::Cpan(opts) => generate_cpan_recipe(&opts).await?,
Source::Luarocks(opts) => generate_luarocks_recipe(&opts).await?,
Source::Pyproject(opts) => generate_pyproject_recipe(&opts).await?,
}
Ok(())
}