-
Notifications
You must be signed in to change notification settings - Fork 485
/
temp.rs
65 lines (50 loc) · 1.71 KB
/
temp.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
use crate::commands::core::get_fetcher;
use crate::common::shell::{self, ShellSpawnError};
use crate::finder::structures::Opts as FinderOpts;
use crate::parser::Parser;
use crate::{prelude::*, serializer};
use std::io::{self, Write};
pub fn main() -> Result<()> {
let config = &CONFIG;
let _opts = FinderOpts::snippet_default();
let fetcher = get_fetcher()?;
let hash: u64 = 2087294461664323320;
let mut buf = vec![];
let mut parser = Parser::new(&mut buf, false);
parser.set_hash(hash);
let _res = fetcher
.fetch(&mut parser)
.context("Failed to parse variables intended for finder")?;
let variables = parser.variables;
let item_str = String::from_utf8(buf)?;
let item = serializer::raycast_deser(&item_str)?;
dbg!(&item);
let x = variables.get_suggestion(&item.tags, "local_branch").expect("foo");
dbg!(&x);
let suggestion_command = x.0.clone();
let child = shell::out()
.stdout(Stdio::piped())
.arg(&suggestion_command)
.spawn()
.map_err(|e| ShellSpawnError::new(suggestion_command, e))?;
let text = String::from_utf8(
child
.wait_with_output()
.context("Failed to wait and collect output from bash")?
.stdout,
)
.context("Suggestions are invalid utf8")?;
dbg!(&text);
Ok(())
}
pub fn _main0() -> Result<()> {
let config = &CONFIG;
let fetcher = get_fetcher()?;
let mut stdout = io::stdout();
let mut writer: Box<&mut dyn Write> = Box::new(&mut stdout);
let mut parser = Parser::new(&mut writer, false);
let _res = fetcher
.fetch(&mut parser)
.context("Failed to parse variables intended for finder")?;
Ok(())
}