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

Enhancements to the CLI command #40

Closed
2 tasks done
she3o opened this issue Oct 4, 2020 · 2 comments
Closed
2 tasks done

Enhancements to the CLI command #40

she3o opened this issue Oct 4, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@she3o
Copy link

she3o commented Oct 4, 2020

First of all, thank you so much for the program! I used to do this cleaning with tedious, slow, and imperfect multiline shell commands. This is my first time using a program like czkawka. I never tried fslint and would like to leave that job for a compiled and highly performant program like czkawka.


I have some suggestions to improve the CLI command:

  • Add an option to separate output by a null character: similiar to how fd and find have a --print0 / -0. That way any output, even directories and files with spaces in their names, could be piped into xargs -0, to be used inside a larger script.

    $ czkawka_cli empty-files -i $HOME -0 | xargs -0I% touch %/not-empty-now.html
    
  • infer -i from current directory if not present: If I run czkawka empty-files from ~/some/directory, I get the error FATAL ERROR: Parameter -i with set of included files is required. It would be much better if it could just run as if -i ~/some/directory and issue a warning that it is running from there. I could live without -i at all if I had that and cd.

  • Use long and short subcommands instead of single-letter arguments with two dashes: i.e.

    $ czkawka ef -i $HOME -delete
    $ czkawka empty-files -i $HOME -delete
    

    This seems more natural to me. I rarely see CLI programs that use the current argument style of czkawka. That will also make it hard to write shell completions since, most shell expect a behaviour similar to GNU coreutils. Of course, I don't know Rust so I can't tell how hard that would be or whether the current CLI was made like that for a certain reason.

  • output of big subcommand is perfect but, it cannot be used inside larger commands because of the prefix ???.?? MiB (?????? bytes) - *

    420.73 MiB (441170444 bytes) - /home/user/Documents/file-1
    418.49 MiB (438823124 bytes) - /home/user/Documents/file-102
    387.79 MiB (406631076 bytes) - /home/user/Music/file-293
    375.57 MiB (393813512 bytes) - /home/user/Downloads/file-555
    

    maybe you could add --short / -S options (or even better: --output / -O <quiet|minimal|verbose|debug> ). In that case I could, for example, find the largest videos with czkawka big and pipe it to ffmpeg for compression. for now my easiest solution would be to use awk or sed in the middle:

    # Does not work
    ~ $ czkawka big -i $HOME -x 'mp4' | xargs ffmpeg {ffmpeg options}
    #Works
    ~ $ czkawka big -i $HOME -x 'mp4' | awk '{$1="";$2="";$3="";$4="";$5=""; print $0}' | xargs ffmpeg {ffmpeg options}
    # Proposed solution, works with spaced filenames too.
    ~ $ czkawka big -x 'mp4' -S -0 | xargs -0 ffmpeg {ffmpeg options} 
    
  • Help is not too helpful: maybe with separate subcommand for each task you could add help to indvidual subcmds in a GNU-generic formatAs of now, the help message dumps everything czkawka could do with very long lines for every subcommand. and there is no man page. It took my a while longer to read compared to other help messages.

  • czkawka is not safe against .git folders. i.e.

~/Documents/project $ czkawka_cli empty-folders -d $(pwd)
    Found 4 empty folders
    /home/user/Documents/project/.git/branches/
    /home/user/Documents/project/.git/objects/info/
    /home/user/Documents/project/.git/objects/pack/
    /home/user/Documents/project/.git/refs/tags/

@qarmin qarmin added the enhancement New feature or request label Oct 5, 2020
@qarmin
Copy link
Owner

qarmin commented Oct 5, 2020

Did you tried to run Czkawka after recent commit e4af905?
Precompiled binaries you can find here - https://github.com/qarmin/czkawka/actions/runs/288322993

App I created mainly for my own usage and it is my first bigger project, so probably a lot of things will not be as they imagine after other software(of course this can be changed if the usefulness of the program will increase)

CLI thanks to MeirKlemp was rewritten with help of StructOpt, so it looks better and have per command help messages, so it should look more similar to Linux commands.

@qarmin qarmin mentioned this issue Oct 7, 2020
@qarmin
Copy link
Owner

qarmin commented Feb 21, 2024

Pipe support will not be added, because already was added json support to app, which is more usable for most of users and is easier to use

@qarmin qarmin closed this as completed Feb 21, 2024
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

2 participants