2018-04-21 21:12:57 +08:00
|
|
|
extern crate isatty;
|
2018-03-07 16:58:01 -07:00
|
|
|
extern crate serde_json;
|
2018-03-27 16:24:05 -06:00
|
|
|
extern crate solana;
|
2018-03-07 16:58:01 -07:00
|
|
|
|
2018-04-21 21:12:57 +08:00
|
|
|
use isatty::stdin_isatty;
|
2018-03-27 16:24:05 -06:00
|
|
|
use solana::mint::Mint;
|
2018-03-07 16:58:01 -07:00
|
|
|
use std::io;
|
2018-04-19 22:55:47 +08:00
|
|
|
use std::process::exit;
|
2018-03-07 16:58:01 -07:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let mut input_text = String::new();
|
2018-04-21 21:12:57 +08:00
|
|
|
if stdin_isatty() {
|
|
|
|
eprintln!("nothing found on stdin, expected a token number");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2018-03-07 16:58:01 -07:00
|
|
|
io::stdin().read_line(&mut input_text).unwrap();
|
|
|
|
let trimmed = input_text.trim();
|
2018-04-21 21:12:57 +08:00
|
|
|
let tokens = trimmed.parse::<i64>().unwrap_or_else(|e| {
|
|
|
|
eprintln!("{}", e);
|
|
|
|
exit(1);
|
|
|
|
});
|
2018-03-07 17:08:12 -07:00
|
|
|
let mint = Mint::new(tokens);
|
2018-04-19 22:55:47 +08:00
|
|
|
let serialized = serde_json::to_string(&mint).unwrap_or_else(|e| {
|
|
|
|
eprintln!("failed to serialize: {}", e);
|
|
|
|
exit(1);
|
|
|
|
});
|
|
|
|
println!("{}", serialized);
|
2018-03-07 16:58:01 -07:00
|
|
|
}
|