From 9290f62a26d48c78c5d509e86b1194fdf8351005 Mon Sep 17 00:00:00 2001 From: Avril Date: Sat, 17 Oct 2020 08:21:29 +0100 Subject: [PATCH] eh --- src/args.rs | 16 +++++++++++++++ src/features.rs | 53 +++++++++++++++++++++++++++++++++++++++++++++++++ src/main.rs | 13 +++++++++++- 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 src/features.rs diff --git a/src/args.rs b/src/args.rs index bee457d..8a58da6 100644 --- a/src/args.rs +++ b/src/args.rs @@ -10,6 +10,22 @@ pub fn program_name() -> &'static str &NAME[..] } +/// Print usage and exit +pub fn usage() -> ! +{ + println!(r#"Videl (versioning delete). + +Usage: {program} [OPTIONS] +Usage: {program} --help + +OPTIONS: + +Compiled with: +{features} +"#, program = program_name(), features = ); + std::process::exit(0) +} + #[inline] pub fn parse() -> ReportedResult { parse_as_args(std::env::args().skip(1)) diff --git a/src/features.rs b/src/features.rs new file mode 100644 index 0000000..a15b3ea --- /dev/null +++ b/src/features.rs @@ -0,0 +1,53 @@ +//! For printing features etc. +use std::{ + fmt, +}; +use cfg_if::cfg_if; + +#[derive(Debug, Clone, PartialEq, Eq, Hash)] +pub enum Enabled +{ + On, + Off, +} + +trait Feature +{ + const DEFAULT: Enabled; + const CURRENT: Enabled; + + const fn is_default() -> bool + { + Self::DEFAULT == Self::CURRENT + } + + const fn is_enabled() -> bool + { + Self::CURRENT == Enabled::On + } +} + +#[macro_export] macro_rules! feature { + ($name:literal) => { + cfg_if!{ + if #[cfg(feature=$name)] { + //TODO: create anony type that impl's Feature up threre, and such + } else { + + } + } + } +} + + + +#[derive(Debug)] +pub struct Features; + +impl fmt::Display for Features +{ + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result + { + //TODO: print features + } +} diff --git a/src/main.rs b/src/main.rs index f80eddc..baa67ec 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,6 +20,7 @@ use error::{ use color_eyre::{ eyre::{ self, + eyre, Result as ReportedResult, }, }; @@ -31,11 +32,21 @@ mod metadata; mod resolve; mod database; mod config; +mod features; mod args; -async fn begin() -> ReportedResult +type Pointer = *const !; + +fn install() -> ReportedResult<()> { color_eyre::install()?; + + Ok(()) +} + +async fn begin() -> ReportedResult +{ + install()?; Ok(0) }