nydus-app

Crates.ionydus-app
lib.rsnydus-app
version0.3.2
sourcesrc
created_at2021-08-15 08:57:43.375117
updated_at2023-01-31 01:58:06.520259
descriptionApplication framework for Nydus Image Service
homepage
repositoryhttps://github.com/dragonflyoss/image-service
max_upload_size
id437177
size27,171
Peng Tao (bergwolf)

documentation

README

nydus-app

The nydus-app crate is a collection of utilities to help creating applications for Nydus Image Service project, which provides:

  • struct BuildTimeInfo: application build and version information.
  • fn dump_program_info(): dump program build and version information.
  • fn setup_logging(): setup logging infrastructure for application.

Support

Platforms:

  • x86_64
  • aarch64

Operating Systems:

  • Linux

Usage

Add nydus-app as a dependency in Cargo.toml

[dependencies]
nydus-app = "*"

Then add extern crate nydus-app; to your crate root if needed.

Examples

  • Setup application infrastructure.
#[macro_use(crate_authors, crate_version)]
extern crate clap;

use clap::App;
use std::io::Result;
use nydus_app::{BuildTimeInfo, setup_logging};

fn main() -> Result<()> {
    let level = cmd.value_of("log-level").unwrap().parse().unwrap();
    let (bti_string, build_info) = BuildTimeInfo::dump();
    let _cmd = App::new("")
        .version(bti_string.as_str())
        .author(crate_authors!())
        .get_matches();

    setup_logging(None, level)?;
    print!("{}", build_info);
    
    Ok(())
}

License

This code is licensed under Apache-2.0.

Commit count: 3109

cargo fmt