diff --git a/src/cli.rs b/src/cli.rs index 62898e9..4c72d25 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -17,6 +17,7 @@ struct Cli { #[derive(Subcommand)] pub enum Commands { + Info, Channels(ChannelsArgs), Clients, Fetch(FetchArgs), diff --git a/src/main.rs b/src/main.rs index d82e91b..1451eb4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -47,6 +47,26 @@ fn main() -> Result<(), Error> { // You can check for the existence of subcommands, and if found use their // matches just as you would the top level cmd match cli { + Commands::Info => { + let client = match wrappers::find_self(&mut connection) { + Ok(client) => client, + Err(msg) => return Err(make_action_error("find self", msg)) + }; + + let channel_name: String = match wrappers::find_channel(&mut connection, "cid", &client.cid.to_string(), true) { + Ok(channel) => match channel { + Some(channel) => channel.channel_name, + None => return Err(to_other_error("Channel not found.".to_string())) + }, + Err(msg) => return Err(make_action_error("find self", msg)) + }; + + println!("Client: {}", client.client_nickname); + println!("Channel: {}", channel_name); + println!("Channel ID: {}", client.cid); + println!("Client ID: {}", client.clid); + } + Commands::Channels(args) => { match wrappers::get_channels(&mut connection, args.spacers) { Ok(channels) => { diff --git a/ts-control b/ts-control index d872875..f791e83 100755 --- a/ts-control +++ b/ts-control @@ -4,6 +4,7 @@ actions="quick move fetch-client fetch-channel +migrate away not away back @@ -45,6 +46,13 @@ _ts_control_fetch() { teamspeak-query-lib fetch "--strict-$1" "--$1" "$target" } +_ts_control_migrate() { + target=$(_ts_control_get_entity "channel" "$2") + current_channel=$(teamspeak-query-lib info | grep "Channel: " | sed 's/Channel: //') + _ts_control_move_self "$target" + teamspeak-query-lib fetch "--strict-channel" "--channel" "$current_channel" +} + _ts_control_single_or_dmenu() { filter="$2" if [ "$filter" == "^$" ]; then @@ -128,6 +136,9 @@ case $action in "fetch-channel") _ts_control_fetch channel "$2" ;; + "migrate") + _ts_control_migrate "$2" + ;; "not away") teamspeak-query-lib move "Not Away From Keyboard" teamspeak-query-lib update --microphone=false --speakers=false