fix host
This commit is contained in:
parent
47b1e7cb89
commit
12a134dcf6
13
README.md
13
README.md
@ -14,15 +14,26 @@ $ ./target/debug/ai ai -t
|
|||||||
### login
|
### login
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# ai t $handle -p $password
|
# ai token $handle -p $password
|
||||||
$ ai t yui.syui.ai -p password
|
$ ai t yui.syui.ai -p password
|
||||||
|
|
||||||
$ cat ~/.config/ai/token.toml
|
$ cat ~/.config/ai/token.toml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# ai token $handle -p $password -s $server
|
||||||
|
$ ai t ai.syu.is -p password -s syu.is
|
||||||
|
```
|
||||||
|
|
||||||
### refresh
|
### refresh
|
||||||
|
|
||||||
```
|
```
|
||||||
$ ai r
|
$ ai r
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### notify
|
||||||
|
|
||||||
|
```
|
||||||
|
$ ai n
|
||||||
|
```
|
||||||
|
|
||||||
|
17
src/main.rs
17
src/main.rs
@ -36,7 +36,12 @@ fn main() {
|
|||||||
.description("password flag")
|
.description("password flag")
|
||||||
.alias("p"),
|
.alias("p"),
|
||||||
)
|
)
|
||||||
|
.flag(
|
||||||
|
Flag::new("server", FlagType::String)
|
||||||
|
.description("server flag")
|
||||||
|
.alias("s"),
|
||||||
)
|
)
|
||||||
|
)
|
||||||
.command(
|
.command(
|
||||||
Command::new("refresh")
|
Command::new("refresh")
|
||||||
.alias("r")
|
.alias("r")
|
||||||
@ -59,9 +64,13 @@ fn token(c: &Context) {
|
|||||||
let m = c.args[0].to_string();
|
let m = c.args[0].to_string();
|
||||||
let h = async {
|
let h = async {
|
||||||
if let Ok(p) = c.string_flag("password") {
|
if let Ok(p) = c.string_flag("password") {
|
||||||
let res = token::post_request(m.to_string(), p.to_string()).await;
|
if let Ok(s) = c.string_flag("server") {
|
||||||
println!("{}", res);
|
let res = token::post_request(m.to_string(), p.to_string(), s.to_string()).await;
|
||||||
w_cfg("bsky.social", &res)
|
w_cfg(&s, &res)
|
||||||
|
} else {
|
||||||
|
let res = token::post_request(m.to_string(), p.to_string(), "bsky.social".to_string()).await;
|
||||||
|
w_cfg(&"bsky.social", &res)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let res = tokio::runtime::Runtime::new().unwrap().block_on(h);
|
let res = tokio::runtime::Runtime::new().unwrap().block_on(h);
|
||||||
@ -86,8 +95,6 @@ fn c_refresh(_c: &Context) {
|
|||||||
refresh();
|
refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fn notify() {
|
fn notify() {
|
||||||
let h = async {
|
let h = async {
|
||||||
let j = notify::get_request(100).await;
|
let j = notify::get_request(100).await;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
extern crate reqwest;
|
extern crate reqwest;
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use crate::url;
|
|
||||||
|
|
||||||
pub async fn post_request(handle: String, pass: String) -> String {
|
pub async fn post_request(handle: String, pass: String, host: String) -> String {
|
||||||
|
|
||||||
let url = url(&"session_create");
|
let url = "https://".to_owned() + &host.to_string() + &"/xrpc/com.atproto.server.createSession".to_string();
|
||||||
|
|
||||||
let mut map = HashMap::new();
|
let mut map = HashMap::new();
|
||||||
map.insert("identifier", &handle);
|
map.insert("identifier", &handle);
|
||||||
|
Loading…
Reference in New Issue
Block a user