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

CLI option to print artifact dirs in plaintext #9

Open
tbillington opened this issue Jan 28, 2020 · 9 comments
Open

CLI option to print artifact dirs in plaintext #9

tbillington opened this issue Jan 28, 2020 · 9 comments
Labels
enhancement New feature or request

Comments

@tbillington
Copy link
Owner

tbillington commented Jan 28, 2020

Reddit user bcgroom mentioned a flag to output just a plain text line separated list of artifact directories. That way it could be passed/manipulated by other programs.

@tbillington
Copy link
Owner Author

implemented with -a CLI flag

@katrinleinweber
Copy link

Hi @tbillington 👋 Thanks for this awesome tool :-)

Can we reopen this? I think the -a/--all flag doesn't quite cover the use case that bcgroom mentioned:

$ kondo --all ~/…
/Users/…/… Node project
  └─ node_modules (2.3MiB)
  deleted 2.3MiB

Projects cleaned: 1, Bytes deleted: 2.3MiB

True, it does output the directory path, but only in combination with the type, and with actually removing the data. It seems more like a --force mode.

However, for "pass[ing to] other programs" something more like a --dry-run or --list-paths option would be nice. I imagine that this would be useful for example to populate a backup exclusion list.

@tbillington
Copy link
Owner Author

It got removed in 7e76b65, so the -a referenced in this issue is a different flag to the one that currently exists.

I do think it's something that should exist though, I'll look at adding it back in. Kondo also used to support an "exec" where you could get kondo to spawn commands/processes for each project/artifact dir but it is harder to support properly than one might imagine so I removed it.

There is a question around the output. Do you only list artifact directories, do you also list the project folder, do you list the project type somewhere? With a JSON output all of that would be probably fine, but if it's just outputting plain text stream it might need to be restricted to just newline separated artifact dirs of all projects found.

Did you have any example use cases in mind to help guide an implementation?

Thanks for bringing this up btw 😃

@tbillington tbillington reopened this Jan 6, 2022
@katrinleinweber
Copy link

only list artifact directories, do you also list the project folder,

The former would be more useful, IMHO, because the artifact directory is the one that is emptied. If a project folder has multiple, they can always be grouped to highlight that fact.

… list the project type somewhere?

Why not, as long as a separator that wouldn't be a valid symbol in a path is used. Any kind of --dry-run or --list-paths option would be more important than the formatting details.

A usecase would be to build a list of exclude patterns, for example for BorgBackup. I mostly use tmignore, however.

@hustcer
Copy link

hustcer commented Apr 1, 2024

Looking forward to adding --recursive and --dry-run options

@tbillington
Copy link
Owner Author

@hustcer kondo is recursive by default. But yes dry run would be helpful. It's not 100% necessary because it won't do anything until you tell it what to do, so dry run is a little less necessary.

The alternate I had in mind was more of a "discovery" command that would list all the projects, types, and sizes without taking any action.

What would you use dry run for ?

@hustcer
Copy link

hustcer commented Apr 1, 2024

kondo is recursive by default.

I don't think so, or maybe a bug? Look at the image below:
Screenshot 2024-04-01 at 19 53 03

What would you use dry run for ?

If the recursive works as expected, I want't to scan all the sub directories and to see if there is any dir need to be cleaned: I don't want to stop and make a choice for each inquiry.

The alternate I had in mind was more of a "discovery" command that would list all the projects, types, and sizes without taking any action.

Great, that should work for my case.

@tbillington
Copy link
Owner Author

@hustcer

Look at the image below:

I should have been more specific, kondo is fully recursive by default (uses walkdir under the hood), however it doesn't recurse inside a found project #29 #55 #117 . I am loosely working on a rework in the background to address it, perhaps see if the description here addresses your use case.

If the recursive works as expected, I want't to scan all the sub directories and to see if there is any dir need to be cleaned: I don't want to stop and make a choice for each inquiry.

To make sure I understand fully, instead of wanting to make a choice at each project, you want to do a dry run that lists everything, then (if you're okay with the output) run kondo again without dry run or interactive mode ?

Aside: there is the -a, --all flag currently which will automatically accept cleaning every found directory.

@hustcer
Copy link

hustcer commented Apr 2, 2024

To make sure I understand fully, instead of wanting to make a choice at each project, you want to do a dry run that lists everything, then (if you're okay with the output) run kondo again without dry run or interactive mode ?

Yes, exactly

I am loosely working on a rework in the background to address it, perhaps see if the #111 addresses your use case.

I have read #111 carefully, I think this feature fulfills my needs, I have just subscribed that issue.

Thanks for the detailed response 👍

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

No branches or pull requests

3 participants