Skip to content

Commit

Permalink
Merge pull request #37 from mycognosist/split_cli
Browse files Browse the repository at this point in the history
Split CLI and application config from main
  • Loading branch information
mycognosist authored Dec 22, 2022
2 parents 977f320 + 3130d1d commit 1dad14c
Show file tree
Hide file tree
Showing 5 changed files with 383 additions and 260 deletions.
3 changes: 1 addition & 2 deletions src/actors/jsonrpc_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ struct PubKey {
///
/// Listens for a termination signal from the broker. When received, the
/// JSON-RPC server is closed and a terminated signal is sent to the broker.
pub async fn actor(server_id: OwnedIdentity, port: u16) -> Result<()> {
pub async fn actor(server_id: OwnedIdentity, server_addr: String) -> Result<()> {
let broker = BROKER
.lock()
.await
Expand Down Expand Up @@ -148,7 +148,6 @@ pub async fn actor(server_id: OwnedIdentity, port: u16) -> Result<()> {
// Return the public key of the local SSB server.
io.add_sync_method("whoami", move |_| Ok(Value::String(local_pk.to_owned())));

let server_addr = format!("0.0.0.0:{}", port);
let server = ServerBuilder::new(io)
.cors(DomainsValidation::AllowOnly(vec![
AccessControlAllowOrigin::Null,
Expand Down
3 changes: 2 additions & 1 deletion src/actors/rpc/history_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ use regex::Regex;
use crate::{
actors::rpc::handler::{RpcHandler, RpcInput},
broker::{BrokerEvent, ChBrokerSend, Destination},
config::{REPLICATION_CONFIG, RESYNC_CONFIG, SECRET_CONFIG},
storage::kv::StoKvEvent,
Result, BLOB_STORAGE, KV_STORAGE, REPLICATION_CONFIG, RESYNC_CONFIG, SECRET_CONFIG,
Result, BLOB_STORAGE, KV_STORAGE,
};

/// Regex pattern used to match blob references.
Expand Down
39 changes: 39 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use std::path::PathBuf;

use structopt::StructOpt;

/// Generate a command line parser.
/// This defines the options that are exposed when running the solar binary.
#[derive(StructOpt, Debug)]
#[structopt(name = "🌞 Solar", about = "Sunbathing scuttlecrabs in kuskaland", version=env!("SOLAR_VERSION"))]
pub struct Cli {
/// Where data is stored (default: ~/.local/share/local)
#[structopt(short, long, parse(from_os_str))]
pub data: Option<PathBuf>,

/// Connect to peers (e.g. host:port:publickey, host:port:publickey)
#[structopt(short, long)]
pub connect: Option<String>,

// TODO: think about other ways of exposing the "connect" feature
/// List of peers to replicate; "connect" magic word means that peers
/// specified with --connect are added to the replication list
#[structopt(short, long)]
pub replicate: Option<String>,

/// Port to bind (default: 8008)
#[structopt(short, long)]
pub port: Option<u16>,

/// Run LAN discovery (default: false)
#[structopt(short, long)]
pub lan: Option<bool>,

/// Run the JSON-RPC server (default: true)
#[structopt(short, long)]
pub jsonrpc: Option<bool>,

/// Resync the local database by requesting the local feed from peers
#[structopt(long)]
pub resync: Option<bool>,
}
Loading

0 comments on commit 1dad14c

Please sign in to comment.