Skip to content

Commit

Permalink
fix: normalize pathname 2
Browse files Browse the repository at this point in the history
- make `std <cmd> ./tgt` work
- previously only relative targets worked in the form `std <cmd> tgt`
  • Loading branch information
blaggacao committed Feb 2, 2022
1 parent e5689f5 commit d7f1d36
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
4 changes: 0 additions & 4 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,5 @@ indent_size = unset
# Rule 5: There are no rules
# http://community.schemewiki.org/cgi-bin/scheme.cgi?scheme-style
[*.scm]
charset = unset
end_of_line = unset
insert_final_newline = unset
trim_trailing_whitespace = unset
indent_style = unset
indent_size = unset
11 changes: 7 additions & 4 deletions cells/std/cli/main.scm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ target:
A target is an absolute or relative path to an organelle of types
'runnables' & 'installables', that optionally specifies an
attribute if the organelle is not a singleton output.

run only available on organelles of type 'runnables'

For example:
Expand Down Expand Up @@ -151,7 +151,10 @@ USAGE
[_ `(error . ,(format "unexpected ~s while parsing ~s target" (car tokens) mode))])))

(define (parse-target target)
(parse-tokens (read-target target)))
(let ((target-str (normalize-pathname target))) ; transforms: // -> /
(parse-tokens (read-target (if (substring=? "/" target-str)
(conc "/" target-str) ; so we put it back in the begining
target-str)))))

;; turn relative targets into absolute targets based on the current
;; directory
Expand Down Expand Up @@ -225,15 +228,15 @@ USAGE
(define (execute-build t)
(let ((url (nix-url-for t)))
(printf "[std] building target ~A~%" t)
(process-execute "nix"
(process-execute "nix"
(list "build" "--option" "warn-dirty" "false" url "--show-trace"))))

(define (build args)
(match args
[() (print "not yet implemented")]

;; single argument should be a target spec
[(arg) (execute-build
[(arg) (execute-build
(guarantee-success (parse-target arg)))]

[other (print "not yet implemented")]))
Expand Down

0 comments on commit d7f1d36

Please sign in to comment.