-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e34a5a
commit 0fd6b21
Showing
2 changed files
with
54 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
use clap::Parser; | ||
use sqlx::SqlitePool; | ||
use torii_storage_sqlite::SqliteStorage; | ||
|
||
#[derive(Parser)] | ||
#[command(author, version, about, long_about = None)] | ||
struct Cli { | ||
/// Enable email authentication | ||
#[arg(long)] | ||
email_auth: bool, | ||
|
||
/// Enable OpenID Connect authentication | ||
#[arg(long)] | ||
oidc_auth: bool, | ||
|
||
/// Database connection string | ||
#[arg(long)] | ||
db_url: String, | ||
|
||
#[command(subcommand)] | ||
command: Commands, | ||
} | ||
|
||
#[derive(clap::Subcommand)] | ||
enum Commands { | ||
/// Run database migrations | ||
Migrate, | ||
/// Print version information | ||
Version, | ||
} | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let cli = Cli::parse(); | ||
|
||
match cli.command { | ||
Commands::Migrate => { | ||
println!("Running migrations..."); | ||
let pool = SqlitePool::connect(&cli.db_url).await.unwrap(); | ||
let storage = SqliteStorage::new(pool); | ||
storage.migrate().await.unwrap(); | ||
} | ||
Commands::Version => { | ||
println!("Torii v{}", env!("CARGO_PKG_VERSION")); | ||
} | ||
} | ||
} |