CLI option and colour.

This commit is contained in:
Gav Wood 2016-06-19 12:28:24 +02:00
parent 3617923d3c
commit 46d588dcae
3 changed files with 13 additions and 2 deletions

View File

@ -109,6 +109,8 @@ API and Console Options:
[default: 8180].
--signer-path PATH Specify directory where Signer UIs tokens should
be stored. [default: $HOME/.parity/signer]
--no-token By default a new system UI security token will be
output on start up. This will prevent it.
Sealing/Mining Options:
--force-sealing Force the node to author new blocks as if it were
@ -255,6 +257,7 @@ pub struct Args {
pub flag_signer: bool,
pub flag_signer_port: u16,
pub flag_signer_path: String,
pub flag_no_token: bool,
pub flag_force_sealing: bool,
pub flag_author: String,
pub flag_usd_per_tx: String,

View File

@ -186,6 +186,13 @@ fn execute_client(conf: Configuration, spec: Spec, client_config: ClientConfig)
let net_settings = conf.net_settings(&spec);
let sync_config = conf.sync_config(&spec);
// Create and display a new token for UIs.
if conf.args.flag_signer && !conf.args.flag_no_token {
new_token(conf.directories().signer).unwrap_or_else(|e| {
die!("Error generating token: {:?}", e)
});
}
// Secret Store
let account_service = Arc::new(conf.account_service());

View File

@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
extern crate ansi_term;
use self::ansi_term::Colour::Red;
use std::io;
use std::path::PathBuf;
use std::sync::Arc;
@ -65,8 +67,7 @@ pub fn new_token(path: String) -> io::Result<()> {
let mut codes = try!(signer::AuthCodes::from_file(&path));
let code = try!(codes.generate_new());
try!(codes.to_file(&path));
println!("New token has been generated. Copy the code below to your Signer UI:");
println!("{}", code);
println!("This key code will authorise your System Signer UI: {}", White.bold().paint(code));
Ok(())
}