Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handing private commands #43

Closed
johnhamelink opened this issue Sep 12, 2023 · 4 comments · Fixed by #60
Closed

Handing private commands #43

johnhamelink opened this issue Sep 12, 2023 · 4 comments · Fixed by #60

Comments

@johnhamelink
Copy link
Contributor

johnhamelink commented Sep 12, 2023

Hi there,

I have a justfile that looks like this:

# Usage info
_default:
    just --list

# Build & switch to new configuration
switch:
  just _rebuild switch \
    --show-trace \
    --fallback \
    --refresh \
    --flake '.#'

[macos]
update:
    nix-channel --update darwin
    darwin-rebuild changelog

[linux]
update:
    sudo nix-channel --update
    sudo nixos-rebuild changelog

[linux]
_rebuild *args:
    sudo nixos-rebuild {{args}}

[macos]
_rebuild *args:
    darwin-rebuild {{args}}

By default, justl shows this:

Screenshot 2023-09-12 at 10 13 57

But _default and _rebuild are private tasks - if I run just --list, I see:

johnhamelink@jh-mbp nix % just --list
Available recipes:
    switch # Build & switch to new configuration
    update

I think this should be the default behaviour.

I was able to fix this by adding seq-remove to justl--parse like so:

diff --git a/justl.el b/justl.el
index 071adb7..fa07ba9 100644
--- a/justl.el
+++ b/justl.el
@@ -371,8 +371,9 @@ Logs the command run."
                         1000))))
         (let ((recipes-entry (assoc 'recipes parsed)))
           (setcdr recipes-entry
-                  (seq-sort (lambda (a b) (< (unsorted-index a) (unsorted-index b)))
-                            (cdr recipes-entry)))
+                  (seq-remove (lambda (r) (equal (alist-get 'private r) t))
+                   (seq-sort (lambda (a b) (< (unsorted-index a) (unsorted-index b)))
+                             (cdr recipes-entry))))
           parsed)))))
 
 (defun justl--get-recipes (justfile)

What do you think? We could use let* and instead optionally filter the list before sorting it against the index, so that previous behaviour could be preserved by enabling a feature-flag?

(Btw Sorry, I haven't had the chance to catch up on #39, I'll try to get to that this week!) fixed!

@psibi
Copy link
Owner

psibi commented Sep 13, 2023

I think this should be the default behaviour.

Yes, I agree.

What do you think? We could use let* and instead optionally filter the list before sorting it against the index, so that previous behaviour could be preserved by enabling a feature-flag?

Sounds good to me.

@johnhamelink
Copy link
Contributor Author

Ok, I might have time to contribute a PR this evening :)

@uqix
Copy link

uqix commented Feb 21, 2024

justl-include-private-recipes does not work, is it supposed to handle this?

@psibi
Copy link
Owner

psibi commented Nov 15, 2024

The latest change handles this, thanks for the report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants