feat: seperate into lib and cli packages
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
[package]
|
||||
name = "soulseek-rs"
|
||||
version.workspace = true
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
description = "Command-line client for Soulseek protocol"
|
||||
keywords = ["soulseek", "p2p", "client", "file-sharing"]
|
||||
categories = ["command-line-utilities"]
|
||||
|
||||
[[bin]]
|
||||
name = "soulseek"
|
||||
path = "src/main.rs"
|
||||
|
||||
[dependencies]
|
||||
# Depend on your library
|
||||
soulseek-rs-lib = { version = "0.1.0", path = "../soulseek-rs-lib" }
|
||||
|
||||
# Add client-specific dependencies here
|
||||
# For example:
|
||||
# clap = { version = "4", features = ["derive"] }
|
||||
# anyhow = "1"
|
||||
@@ -0,0 +1,26 @@
|
||||
# soulseek-rs
|
||||
|
||||
A command-line client for the Soulseek peer-to-peer network.
|
||||
|
||||
## Installation
|
||||
|
||||
`bash cargo install soulseek-rs `
|
||||
|
||||
This will install the `soulseek` binary to your system.
|
||||
|
||||
## Usage
|
||||
|
||||
The client provides a simple interface to search and download files from the
|
||||
Soulseek network.
|
||||
|
||||
## Building from Source
|
||||
|
||||
````bash git clone https://github.com/yourusername/soulseek-rs cd soulseek-rs
|
||||
cargo build --release ```
|
||||
|
||||
## Library
|
||||
|
||||
If you want to build your own Soulseek client, check out the
|
||||
[soulseek-rs-lib](https://crates.io/crates/soulseek-rs-lib) library crate.
|
||||
|
||||
````
|
||||
@@ -0,0 +1,34 @@
|
||||
use soulseek_rs::{Client, PeerAddress};
|
||||
use std::time::Duration;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create and connect to Soulseek server
|
||||
let mut client = Client::new(
|
||||
PeerAddress::new("server.slsknet.org".to_string(), 2242),
|
||||
"username".to_string(),
|
||||
"password".to_string(),
|
||||
false,
|
||||
None,
|
||||
);
|
||||
|
||||
client.connect();
|
||||
client.login()?;
|
||||
|
||||
// Search for files
|
||||
let results =
|
||||
client.search("Alex Kassian lifestream", Duration::from_secs(10))?;
|
||||
|
||||
// Download first available file
|
||||
if let Some(result) = results.iter().find(|r| !r.files.is_empty()) {
|
||||
let file = &result.files[0];
|
||||
client.download(
|
||||
file.name.clone(),
|
||||
file.username.clone(),
|
||||
file.size,
|
||||
"~/Downloads".to_string(),
|
||||
)?;
|
||||
println!("Downloaded: {}", file.name);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user