generated from PlexSheep/rs-base
Compare commits
No commits in common. "d87d5d02dafa19a2a6ff2db7cccaee45135f2b98" and "947636cf0a79a527f365314211d522e6020c884e" have entirely different histories.
d87d5d02da
...
947636cf0a
2 changed files with 1 additions and 31 deletions
11
README.md
11
README.md
|
@ -24,7 +24,7 @@ Current formats are:
|
||||||
- Base32
|
- Base32
|
||||||
- Base64
|
- Base64
|
||||||
|
|
||||||
`numf` also has the option of prepending a prefix for each format, such as
|
`numf` also has the onumfion of prepending a prefix for each format, such as
|
||||||
`0x` for hexadecimal. Numbers may also be provided from the stdin. See `--help`
|
`0x` for hexadecimal. Numbers may also be provided from the stdin. See `--help`
|
||||||
flag for more information.
|
flag for more information.
|
||||||
|
|
||||||
|
@ -36,12 +36,3 @@ $ numf -xp 1337 505 0xaabb
|
||||||
0x1F9
|
0x1F9
|
||||||
0xAABB
|
0xAABB
|
||||||
```
|
```
|
||||||
## Installing
|
|
||||||
|
|
||||||
### Cargo
|
|
||||||
|
|
||||||
`numf` is on [crates.io](https://crates.io).
|
|
||||||
|
|
||||||
```
|
|
||||||
cargo install numf
|
|
||||||
```
|
|
||||||
|
|
|
@ -1,29 +1,8 @@
|
||||||
//! This module implements the actual formatting in [numf](crate).
|
|
||||||
//!
|
|
||||||
//! You can use it in your own program to convert numbers to formats.
|
|
||||||
//!
|
|
||||||
//! # Example
|
|
||||||
//!
|
|
||||||
//! The following example shows how to use numf to format your integers.
|
|
||||||
//!
|
|
||||||
//! ```
|
|
||||||
//! use numf::format::{Format, FormatOptions};
|
|
||||||
//!
|
|
||||||
//! let mut options = FormatOptions::default();
|
|
||||||
//! options.set_prefix(true);
|
|
||||||
//! options.set_padding(true);
|
|
||||||
//!
|
|
||||||
//! assert_eq!(Format::Hex.format(0x1337, &options), "0x1337");
|
|
||||||
//! assert_eq!(Format::Base32.format(0x41414242, &options), "032sIFAUEQQ=");
|
|
||||||
//! assert_eq!(Format::Base64.format(0x41414242, &options), "0sQUFCQg==");
|
|
||||||
//! ```
|
|
||||||
|
|
||||||
#![allow(dead_code)] // this is exported to lib.rs
|
#![allow(dead_code)] // this is exported to lib.rs
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use clap::{ArgGroup, Parser};
|
use clap::{ArgGroup, Parser};
|
||||||
use libpt::bintols::{join, split};
|
use libpt::bintols::{join, split};
|
||||||
|
|
||||||
/// The number type [numf](crate) uses
|
|
||||||
pub type NumberType = u128;
|
pub type NumberType = u128;
|
||||||
|
|
||||||
/// formats supported by numf
|
/// formats supported by numf
|
||||||
|
|
Reference in a new issue