feat: types described, examples of registry
This commit is contained in:
parent
f85bd1d03f
commit
7a77314eaf
5 changed files with 40 additions and 22 deletions
|
@ -1,6 +1,6 @@
|
|||
# Browser command line
|
||||
|
||||
The idea is to transform api methods in command line interface
|
||||
The idea is to transform api methods into command line interface
|
||||
|
||||
The default shell command, like:
|
||||
|
||||
|
@ -24,7 +24,7 @@ wacli ain <tool.dns>
|
|||
|
||||
On your website you will need to use `.well-know/wacli.json` file:
|
||||
|
||||
```jsonc
|
||||
```js
|
||||
{
|
||||
"api": "<api_url>",
|
||||
"bin": {
|
||||
|
@ -38,7 +38,7 @@ On your website you will need to use `.well-know/wacli.json` file:
|
|||
"headers": Array<headers>,
|
||||
"aliases": [{
|
||||
"alias": "<short_hand>" | ["short_hand","long_hand"],
|
||||
"type": "path" | "method" | "bin",
|
||||
"type": "path" | "method" | "bin" | "uri",
|
||||
"description": "description of cli command"
|
||||
"content": "<path>"
|
||||
}],
|
||||
|
@ -152,7 +152,7 @@ You can create registry, by writing to `.well-know/wacli.json` next lines
|
|||
You can also get help on all api methods using the command
|
||||
|
||||
```sh
|
||||
wacli help codeberg.org
|
||||
wacli help git.0ut0f.space
|
||||
```
|
||||
|
||||
Settings format is on Linux by address `$HOME/.config/wacli/wacfg.json`
|
||||
|
|
8
examples/settings.json
Normal file
8
examples/settings.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"db_path": "$HOME/.cache/wacrd.db",
|
||||
"install_dir": "$HOME/.local/bin",
|
||||
"uri_schemes": {
|
||||
"registry": "https://wacli.ofs.lol"
|
||||
}
|
||||
}
|
||||
|
16
examples/wacli.ofs.lol/.well-known/wacli.json
Normal file
16
examples/wacli.ofs.lol/.well-known/wacli.json
Normal file
|
@ -0,0 +1,16 @@
|
|||
{
|
||||
"registry": true,
|
||||
"manifests": {
|
||||
"forgejo": {
|
||||
"path": "https://wacli.ofs.lol/registry/forgejo.json"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"aliases": [{
|
||||
"type": "uri",
|
||||
"alias": "registry",
|
||||
"content": "https://wacli.ofs.lol"
|
||||
}]
|
||||
}
|
||||
}
|
||||
|
30
src/main.zig
30
src/main.zig
|
@ -1,24 +1,18 @@
|
|||
const std = @import("std");
|
||||
|
||||
pub fn main() !void {
|
||||
// Prints to stderr (it's a shortcut based on `std.io.getStdErr()`)
|
||||
std.debug.print("All your {s} are belong to us.\n", .{"codebase"});
|
||||
const OauthFlows = struct { implict: struct { authrizationUrl: []const u8, scopes: std.StringHashMap([]const u8) } };
|
||||
|
||||
// stdout is for the actual output of your application, for example if you
|
||||
// are implementing gzip, then only the compressed bytes should be sent to
|
||||
// stdout, not any debugging messages.
|
||||
const stdout_file = std.io.getStdOut().writer();
|
||||
var bw = std.io.bufferedWriter(stdout_file);
|
||||
const stdout = bw.writer();
|
||||
const WellKnownSettings = struct {
|
||||
contentType: []const u8 = "application/json",
|
||||
headers: ?[]const ([]const u8),
|
||||
aliases: ?[]const struct { aliases: union { string: []const u8, array: []const []const u8 }, type: enum { path, method, bin, uri }, description: ?[]const u16, content: ?[]const u8 },
|
||||
auth: ?struct { scheme: enum { basic, bearer, oauth2 }, tokenName: ?[]const u8, flows: ?OauthFlows },
|
||||
};
|
||||
|
||||
try stdout.print("Run `zig build test` to run the tests.\n", .{});
|
||||
const WellKnownSchema = struct { api: ?[]const u8, registry: bool = false, manifests: ?std.StringHashMap(struct { path: []const u8 }), bin: ?[]const std.StringHashMap([]const u8), settings: WellKnownSettings };
|
||||
|
||||
try bw.flush(); // don't forget to flush!
|
||||
}
|
||||
const UserSettings = struct { db_path: []const u8 = "$HOME/.cache/wacrd.bin", install_dir: []const u8 = "$HOME/.local/bin", uri_shemes: ?std.StringHashMap([]const u8) };
|
||||
|
||||
test "simple test" {
|
||||
var list = std.ArrayList(i32).init(std.testing.allocator);
|
||||
defer list.deinit(); // try commenting this out and see if zig detects the memory leak!
|
||||
try list.append(42);
|
||||
try std.testing.expectEqual(@as(i32, 42), list.pop());
|
||||
}
|
||||
pub fn main() !void {}
|
||||
|
||||
test "spec" {}
|
||||
|
|
Loading…
Reference in a new issue