From 692c455f1829950aa9376f6fbcb0df4192dcfb73 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Wed, 11 May 2022 13:06:10 -0500 Subject: [PATCH] Make paths absolute and append file:// before publishing --- README.md | 1 - src/xdg_open.nim | 9 +++++++-- uri_runner.pr | 3 +++ xdg_open_ng.nimble | 2 +- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 50099e1..4ed1aa5 100644 --- a/README.md +++ b/README.md @@ -7,5 +7,4 @@ There are two utilites, `xdg-open` and `uri_runner`. The former connects to a sh The [protocol.nim](./src/protocol.nim) file is generated from the [protocol.prs](./protocol.prs) schema, a [Tupfile](https://gittup.org/tup/) file is provided to do this. ## TODO -- Pattern back-references in commands - Fallback commands? diff --git a/src/xdg_open.nim b/src/xdg_open.nim index 1a594e8..3218923 100644 --- a/src/xdg_open.nim +++ b/src/xdg_open.nim @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Unlicense import std/[asyncdispatch, os] -import preserves +from std/sequtils import map import syndicate, syndicate/capabilities import ./protocol @@ -17,7 +17,12 @@ proc mintCap: SturdyRef = bootDataspace("main") do (root: Ref; turn: var Turn): connectUnix(turn, unixSocketPath(), mintCap()) do (turn: var Turn; ds: Ref): - message(turn, ds, XdgOpen(uris: commandLineParams())) + var uris = commandLineParams().map do (param: string) -> string: + if fileExists param: + "file://" & absolutePath(param) + else: + param + message(turn, ds, XdgOpen(uris: uris)) for i in 0..7: poll(20) # A hack to exit diff --git a/uri_runner.pr b/uri_runner.pr index 35837c1..57800bb 100644 --- a/uri_runner.pr +++ b/uri_runner.pr @@ -25,5 +25,8 @@ let ?root_ds = dataspace + + ; filesystem paths are always prefixed with file:// + ] ] diff --git a/xdg_open_ng.nimble b/xdg_open_ng.nimble index db2eb23..ed70d17 100644 --- a/xdg_open_ng.nimble +++ b/xdg_open_ng.nimble @@ -1,6 +1,6 @@ # Package -version = "0.3.1" +version = "0.3.2" author = "Emery" description = "A better xdg-open" license = "Unlicense"