Skip to content

Commit 8511f3d

Browse files
zadjii-msftDHowett
andauthored
Add a spec for "Snippets" (#17329)
This specs out a lot of plans for snippets. We've already got these in the sxnui as "tasks", but we can do so very much more. This spec is a few years old now, but it's time for it to get promoted out of my draft branch. References: * #1595 * #7039 * #3121 * #10436 * #12927 * #12857 * #5790 * #15845 --------- Co-authored-by: Dustin L. Howett <[email protected]>
1 parent fa40733 commit 8511f3d

24 files changed

+695
-0
lines changed

.github/actions/spelling/allow/allow.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ perlw
5050
postmodern
5151
Powerline
5252
ptys
53+
pwn
5354
pwshw
5455
qof
5556
qps
@@ -80,6 +81,7 @@ und
8081
vsdevcmd
8182
westus
8283
workarounds
84+
wtconfig
8385
XBox
8486
YBox
8587
yeru

doc/specs/#1595 - Suggestions UI/Snippets.md

Lines changed: 648 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import yaml
2+
import json
3+
import sys
4+
import os
5+
6+
def parse_yaml_files(tool, directory):
7+
json_data = {}
8+
json_data["name"] = f"{tool}..."
9+
json_data["commands"] = []
10+
11+
for filename in os.listdir(directory):
12+
if filename.endswith(".yaml") or filename.endswith(".yml"):
13+
file_path = os.path.join(directory, filename)
14+
with open(file_path, 'r', encoding="utf-8") as file:
15+
try:
16+
yaml_data = yaml.safe_load(file)
17+
new_obj = {}
18+
command = {}
19+
command["input"] = yaml_data["command"]
20+
command["action"] ="sendInput"
21+
22+
new_obj["command"]=command
23+
new_obj["name"] = yaml_data["name"]
24+
25+
new_obj["description"] = yaml_data["description"] if "description" in yaml_data else ""
26+
json_data["commands"].append(new_obj)
27+
except yaml.YAMLError as e:
28+
print(f"Error parsing {filename}: {e}")
29+
sys.exit(-1)
30+
return json_data
31+
32+
def main(directory) -> int:
33+
json_data = {}
34+
json_data["actions"] = []
35+
36+
for tool_dir in os.listdir(directory):
37+
# print(tool_dir)
38+
json_data["actions"].append(parse_yaml_files(tool_dir, os.path.join(directory, tool_dir)))
39+
print(json.dumps(json_data, indent=4))
40+
return 0
41+
42+
if __name__ == '__main__':
43+
# Write this output to something like
44+
# "%localappdata%\Microsoft\Windows Terminal\Fragments\warp-workflows\actions.json"
45+
sys.exit(main("d:\\dev\\public\\workflows\\specs"))
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)