add lib, partition both application files, c-line input
This commit is contained in:
parent
27e13d6a90
commit
144453c692
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rust-irc"
|
||||||
|
version = "0.1.0"
|
4
src/client.rs
Normal file
4
src/client.rs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
pub fn start() {
|
||||||
|
println!("Starting the IRC client");
|
||||||
|
todo!();
|
||||||
|
}
|
19
src/lib.rs
Normal file
19
src/lib.rs
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
pub mod codes {
|
||||||
|
pub mod client {
|
||||||
|
pub const JOIN_ROOM: u8 = 0x01;
|
||||||
|
pub const JOIN_SERVER: u8 = 0x02;
|
||||||
|
pub const LEAVE_ROOM: u8 = 0x03;
|
||||||
|
pub const LIST_ROOMS: u8 = 0x04;
|
||||||
|
pub const SEND_MESSAGE: u8 = 0x05;
|
||||||
|
}
|
||||||
|
pub const KEEP_ALIVE: u8 = 0x0C;
|
||||||
|
pub const RESPONSE: u8 = 0x0D;
|
||||||
|
pub const RESPONSE_OK: u8 = 0x0E;
|
||||||
|
pub const ERROR: u8 = 0x0F;
|
||||||
|
pub const QUIT: u8 = 0x0B;
|
||||||
|
pub mod error {
|
||||||
|
pub const INVALID_ROOM: u8 = 0x10;
|
||||||
|
pub const NICKNAME_COLLISION: u8 = 0x11;
|
||||||
|
pub const SERVER_FULL: u8 = 0x12;
|
||||||
|
}
|
||||||
|
}
|
30
src/main.rs
30
src/main.rs
@ -1,3 +1,29 @@
|
|||||||
fn main() {
|
use std::env;
|
||||||
println!("Hello, world!");
|
|
||||||
|
mod client;
|
||||||
|
mod server;
|
||||||
|
|
||||||
|
fn parsechar(s: &str) -> char {
|
||||||
|
s.parse().unwrap_or_else(|_| info())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn info() -> ! {
|
||||||
|
println!("Start client: cargro run c\nStart server: cargo run s");
|
||||||
|
std::process::exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let args: Vec<String> = env::args().skip(1).collect();
|
||||||
|
if args.len() == 1 {
|
||||||
|
let input: char = parsechar(&args[0]);
|
||||||
|
if input == 'c' {
|
||||||
|
client::start();
|
||||||
|
} else if input == 's' {
|
||||||
|
server::start();
|
||||||
|
} else {
|
||||||
|
info();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
info();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
4
src/server.rs
Normal file
4
src/server.rs
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
pub fn start() {
|
||||||
|
println!("Starting the IRC Server");
|
||||||
|
todo!();
|
||||||
|
}
|
Reference in New Issue
Block a user