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

use relative file path in CommandLineFormatter #680

Merged
merged 6 commits into from
Jun 13, 2022

Conversation

dlech
Copy link
Contributor

@dlech dlech commented Jun 2, 2022

This changes the format of the file name to add a leading "." so that the path is a relative path instead of an absolute path.

Modern terminal programs allow control-clicking on paths to jump to a file, so if this is a relative path, we can jump to the file. If it is printed as an absolute path, this doesn't work.

This changes the format of the file name to add a leading "." so that
the path is a relative path instead of an absolute path.

Modern terminal programs allow control-clicking on paths to jump to a
file, so if this is a relative path, we can jump to the file. If it is
printed as an absolute path, this doesn't work.
@belav belav added this to the 0.18.0 milestone Jun 2, 2022
@belav
Copy link
Owner

belav commented Jun 2, 2022

I think this is a great idea but I did find a couple issues.

I think I added a unit test to recreate the first, but I am having trouble running the unit tests right now. The source generators are causing me some pain after I started looking at supporting c# 11. I at least managed to build things so that I could test the cli.

  1. Passing a subdirectory as a path, the relative path output isn't correct
PS C:\projects> dotnet csharpier csharpier  
Error /Src/CSharpier.Generators/NodePrinterGenerator.cs - Failed to compile so was not formatted.

PS C:\projects> C:\projects\csharpier\Src\CSharpier.Cli\bin\Debug\net6.0\dotnet-csharpier.exe csharpier
Error .Src/CSharpier.Generators/NodePrinterGenerator.cs - Failed to compile so was not formatted.
  1. Passing a fully qualified path, csharpier currently outputs a path relative to the path that was input (although missing the .) - to get it clickable would require it to be relative to the current directory, or a fully qualified path. Maybe the fully qualified path makes more sense, because the path supplied was fully qualified.
PS C:\projects> dotnet csharpier c:\projects\csharpier
Error /Src/CSharpier.Generators/NodePrinterGenerator.cs - Failed to compile so was not formatted.

PS C:\projects> C:\projects\csharpier\Src\CSharpier.Cli\bin\Debug\net6.0\dotnet-csharpier.exe c:\projects\csharpier
Error .Src/CSharpier.Generators/NodePrinterGenerator.cs - Failed to compile so was not formatted.

@belav
Copy link
Owner

belav commented Jun 2, 2022

I may have my terminology confused.
I intended csharpier to output paths relative to the path that was supplied to be formatted, but they were missing the ..

If csharpier is supplied a relative path, like . or Subdirectory, then it should output a relative path that is clickable.
If csharpier is supplied an absolute path, like c:/projects/csharpier, then it should probably output an absolute path that is clickable.

And it looks like if you supply a path as ./Subdirectory then csharpier fails. I am going to create a bug for that.

belav
belav previously approved these changes Jun 13, 2022
@belav belav merged commit a56a47a into belav:master Jun 13, 2022
@dlech dlech deleted the relative-path branch June 13, 2022 18:09
@dlech
Copy link
Contributor Author

dlech commented Jun 13, 2022

Thanks for fixing this up. I didn't have time to get back to it yet.

@belav
Copy link
Owner

belav commented Jun 13, 2022

You're welcome!

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 this pull request may close these issues.

None yet

2 participants