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

unable to use ~/ as path to file #336

Closed
xakrurychle opened this issue Jul 4, 2023 · 7 comments
Closed

unable to use ~/ as path to file #336

xakrurychle opened this issue Jul 4, 2023 · 7 comments
Labels
3rd party deficiency fcli's ability to add new functionality is effected by a deficiency of a 3rd party enhancement New feature or request

Comments

@xakrurychle
Copy link

fcli ssc appversion-artifact upload ~/here.fpr --appversion ::myFCLICreatedVersion::
Autocompletion for the upload option does not work with ~/xyz but works with /home/user/xyz

@rsenden
Copy link
Contributor

rsenden commented Jul 5, 2023

The auto-completion script is generated by the CLI framework that we're using, so we don't have direct control over the contents. We'd need to wait for a patch (or contribute a patch ourselves).

@wtfacoconut Can you please confirm this issue, and then report this on the picocli issues page? Of course, if you can develop a patch, that would be even better.

@rsenden rsenden added 3rd party bug Bugs that exist in software from 3rd parties picocli labels Jul 5, 2023
@MikeTheSnowman
Copy link
Collaborator

MikeTheSnowman commented Jul 6, 2023

fcli ssc appversion-artifact upload ~/here.fpr --appversion ::myFCLICreatedVersion:: Autocompletion for the upload option does not work with ~/xyz but works with /home/user/xyz

Hey @xakrurychle , it's somewhat clear that you're doing this from some kind of *nix shell. Can you detail which OS and shell you're running fcli from?

Also, when you say "autocompletion", are you saying that you're running the command fcli ssc appversion-artifact upload ~/here.fpr --appversion ::myFCLICreatedVersion:: and fcli is simply throwing an exception because the full absolute path to the fpr file wasn't provided?
Or are you saying that you tried to double-tap the <tab> key on ~/here.fpr where by your expecting for the shell to then fully expand that parameter to a full path?

@xakrurychle
Copy link
Author

fcli ssc appversion-artifact upload ~/here.fpr --appversion ::myFCLICreatedVersion:: Autocompletion for the upload option does not work with ~/xyz but works with /home/user/xyz

Hey @xakrurychle , it's somewhat clear that you're doing this from some kind of *nix shell. Can you detail which OS and shell you're running fcli from?

$ $SHELL --version
GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)

$ cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

Also, when you say "autocompletion", are you saying that you're running the command fcli ssc appversion-artifact upload ~/here.fpr --appversion ::myFCLICreatedVersion:: and fcli is simply throwing an exception because the full absolute path to the fpr file wasn't provided? Or are you saying that you tried to double-tap the <tab> key on ~/here.fpr where by your expecting for the shell to then fully expand that parameter to a full path?

What I mean by autocompletion is the latter you mention. Using ~/ won't allow me to use <tab> to finish the path, using full-scalled /home/.../.../ allowed for <tab> completion.

@rsenden rsenden added enhancement New feature or request 3rd party deficiency fcli's ability to add new functionality is effected by a deficiency of a 3rd party and removed 3rd party bug Bugs that exist in software from 3rd parties labels Jul 17, 2023
@rsenden
Copy link
Contributor

rsenden commented Jul 17, 2023

Being a Java application, fcli doesn't support ~ to represent a home directory out of the box, hence the auto-completion script doesn't recognize this either. If you try passing ~/some/path to an fcli option taking a path/file, fcli will fail with an error indicating that the path cannot be found.

Potentially we could manually implement ~ support for every fcli option that takes a file/path as input. Not sure though whether we can implement this in a generic way; potentially we'd need to have custom logic in every applicable fcli command, thereby making it difficult to provide and maintain consistency between the different commands.

If we choose to implement support for ~, it remains to be seen whether the auto-completion script can also be tailored to support this. Also, we'd only be able to support a plain ~ to represent the home directory of the current user; expanding ~otherUser is a shell feature which cannot be implemented in a cross-platform way.

@xakrurychle
Copy link
Author

The reason for raising this is because I use fortifyclient on daily basis and using FCLI as a successor with extended options and possibilities, the absence of tabbing feature for ~/ path became visible basically immediatelly.

@rsenden
Copy link
Contributor

rsenden commented Jul 18, 2023

Further research leads to remkop/picocli#437 (comment), describing how to have any File option automatically recognize ~. Further research shows that this work-around is usually not necessary, as shells that natively support ~ already expand this to the user's home directory before passing the value to fcli. Unfortunately, auto-completion for paths starting with ~ doesn't seem to work either with or without this work-around being present.

I've opened a new picocli issue to request input on this issue: remkop/picocli#2068

As a side node, filename auto-completion only seems to be applicable to options or parameters declared as File or Path. We have various options that take a filename as a String, like --log-file and --output-file, so directory/file name completion doesn't work for these options. We should fix this as well. I can't think of any generic way to verify which options throughout fcli are supposed to take a file name though, so this will be a manual process.

@rsenden
Copy link
Contributor

rsenden commented Jul 19, 2023

Further research shows that this issue only affects positional parameters; completion candidates are correctly shown when ~/ is used on options (as long as these are declared to take File or Path instances; see #351)

rsenden added a commit that referenced this issue Jul 19, 2023
…artial fix for #336 & #351)

fix: Enable auto-completion on all options/parameters taking a file/directory (partial fix for #336 & #351)

fix: Improve handling of destination directories contain .. for tool * install commands (fixes #345)
@rsenden rsenden modified the milestones: backlog, await-3rd-party Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3rd party deficiency fcli's ability to add new functionality is effected by a deficiency of a 3rd party enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants