Skip to content

Commit

Permalink
Add start of new shadcn CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Oct 3, 2024
1 parent 518b180 commit af8a65d
Show file tree
Hide file tree
Showing 9 changed files with 144 additions and 4 deletions.
40 changes: 37 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[workspace]
members = ["book-examples/*", "packages/cli", "packages/leptos/*"]
members = [
"book-examples/*",
"packages/cli",
"packages/leptos/*",
"packages/shadcn",
]
resolver = "2"

[workspace.package]
Expand Down
20 changes: 20 additions & 0 deletions packages/shadcn/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "shadcn"
description = "Rust port of shadcn CLI."

authors.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
version.workspace = true

[dependencies]
anyhow = "1.0.89"
clap = { version = "4.5.4", features = ["cargo", "derive"] }
env_logger = "0.11.3"
log.workspace = true
reqwest = { version = "0.12.4", features = ["gzip", "json"] }
serde = { version = "1.0.203", features = ["derive"] }
serde_json = "1.0.117"
tokio = { version = "1.38.0", features = ["full"] }
toml = "0.8.14"
41 changes: 41 additions & 0 deletions packages/shadcn/src/bin/rust-shadcn.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
use anyhow::Result;
use clap::{Args, Parser, Subcommand};
use shadcn::commands::init::{init, InitOptions};

#[derive(Parser)]
#[command(version, propagate_version = true)]
#[command(about = "add components and dependencies to your project")]
// #[command(subcommand_required = true)]
struct Cli {
#[command(subcommand)]
command: Commands,
}

#[derive(Subcommand)]
enum Commands {
#[command(about = "add a component to your project")]
Add(AddArgs),
#[command(about = "check for updates against the registry")]
Diff(DiffArgs),
#[command(about = "initialize your project and install dependencies")]
Init(InitOptions),
}

#[derive(Args)]
struct AddArgs {}

#[derive(Args)]
struct DiffArgs {}

#[tokio::main]
async fn main() -> Result<()> {
env_logger::init();

let cli = Cli::parse();

match cli.command {
Commands::Add(args) => Ok(()),
Commands::Diff(args) => Ok(()),
Commands::Init(args) => init(args).await,
}
}
3 changes: 3 additions & 0 deletions packages/shadcn/src/commands.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub mod add;
pub mod diff;
pub mod init;
Empty file.
Empty file.
36 changes: 36 additions & 0 deletions packages/shadcn/src/commands/init.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use std::path::PathBuf;

use anyhow::Result;
use clap::Args;

#[derive(Args)]
pub struct InitOptions {
#[arg(help = "the components to add or a url to the component.")]
components: Vec<String>,

#[arg(short, long, help = "skip confirmation prompt.")]
yes: bool,

#[arg(short, long, help = "use default configuration.")]
defaults: bool,

#[arg(short, long, help = "force overwrite of existing configuration.")]
force: bool,

#[arg(
short,
long,
help = "the working directory. defaults to the current directory."
)]
cwd: PathBuf,

#[arg(short, long, help = "mute output.")]
silent: bool,

#[arg(long, help = "use the src directory when creating a new project.")]
src_dir: bool,
}

pub async fn init(options: InitOptions) -> Result<()> {
Ok(())
}
1 change: 1 addition & 0 deletions packages/shadcn/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod commands;

0 comments on commit af8a65d

Please sign in to comment.