-
Notifications
You must be signed in to change notification settings - Fork 68
#1788: Created a commandlet to simulate the behaviour of ln -s #1847
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
Open
KarimALotfy
wants to merge
35
commits into
devonfw:main
Choose a base branch
from
KarimALotfy:feature/1788-add-ln-commandlet-to-create-links
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
7cf83da
#1788: Created a commandlet to simulate the behaviour of ln -s
KarimALotfy 818f7a4
Merge 'main' into 'feature/1788-add-ln-commandlet-to-create-link'
KarimALotfy d9d1101
#1788: Refactored LnCommandlet
KarimALotfy e1182c0
#1788: Merge with upstream main
KarimALotfy 0e14ba4
#1788: Fix bug in order of val in Help.pro
KarimALotfy 61a560d
#1788: Made -s flag optional, enabling both options of symbolic or ha…
KarimALotfy d0e5bf9
Merge branch "main" into "feature/1788-add-ln-commandlet-to-create-li…
KarimALotfy 46236f2
#1788: Fix change in Help.properties
KarimALotfy 3116b1c
Merge branch 'main' into feature/1788-add-ln-commandlet-to-create-links
KarimALotfy ecabdb9
#1788: Change naming from target to source
KarimALotfy 4d9db9a
Merge branch 'feature/1788-add-ln-commandlet-to-create-links' of http…
KarimALotfy 8da6d74
Merge branch 'main' of https://github.com/devonfw/IDEasy into feature…
KarimALotfy aa91650
#1788: Refactored link by making the overriding functionality optional
KarimALotfy 7f733f8
Merge branch 'main' into feature/1788-add-ln-commandlet-to-create-links
hohwille 1221f3c
#1788: Replaced force flag with the global force option
KarimALotfy 568d3ed
Merge banch "main" into "feature/1788-add-ln-commandlet-to-create-links
KarimALotfy 88df80b
Merge branch 'feature/1788-add-ln-commandlet-to-create-links' of http…
KarimALotfy cf7dc41
#1788 : Remove unneeded test, since the -f option is irrelevant to sy…
KarimALotfy 00fb7df
Merge branch 'main' into feature/1788-add-ln-commandlet-to-create-links
hohwille bd3a739
Merge branch 'main' into feature/1788-add-ln-commandlet-to-create-links
KarimALotfy a031666
Merge branch 'main' into feature/1788-add-ln-commandlet-to-create-links
KarimALotfy 197fc07
Merge branch 'main' into feature/1788-add-ln-commandlet-to-create-links
KarimALotfy fdac6b9
Merge branch 'main' into feature/1788-add-ln-commandlet-to-create-links
hohwille 77b001d
#1788 : Refactored LnCommandlet
KarimALotfy dfe6211
Merge branch 'feature/1788-add-ln-commandlet-to-create-links' of http…
KarimALotfy 2503d34
Merge branch 'main' of https://github.com/devonfw/IDEasy into feature…
KarimALotfy 1140604
#1788 : fix
KarimALotfy 010935d
Merge branch 'main' into feature/1788-add-ln-commandlet-to-create-links
KarimALotfy 56c577b
Merge branch 'main' into feature/1788-add-ln-commandlet-to-create-links
KarimALotfy 9a4a38a
#1788: Refactor LnCommandlet
KarimALotfy 5e23c49
Merge branch 'feature/1788-add-ln-commandlet-to-create-links' of http…
KarimALotfy 177aa64
Merge branch 'main' of https://github.com/devonfw/IDEasy into feature…
KarimALotfy cdadf35
#1788: Simplify createHardLink
KarimALotfy 2f60435
#1788: Fix test
KarimALotfy 9e342cd
#1788: Fix test
KarimALotfy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -14,7 +14,6 @@ | |
| !.anyedit.properties | ||
| !.ide.properties | ||
| !.templateengine | ||
| !.github | ||
| target/ | ||
| eclipse-target/ | ||
| generated/ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
cli/src/main/java/com/devonfw/tools/ide/commandlet/LnCommandlet.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| package com.devonfw.tools.ide.commandlet; | ||
|
|
||
| import java.nio.file.Files; | ||
| import java.nio.file.Path; | ||
|
|
||
| import com.devonfw.tools.ide.cli.CliException; | ||
| import com.devonfw.tools.ide.context.IdeContext; | ||
| import com.devonfw.tools.ide.io.PathLinkType; | ||
| import com.devonfw.tools.ide.property.FlagProperty; | ||
| import com.devonfw.tools.ide.property.PathProperty; | ||
|
|
||
| /** | ||
| * // * Link creation {@link Commandlet} similar to {@code ln -s}. | ||
| * <p> | ||
| * It tries to create a true symbolic link first. On Windows, symlink creation may be restricted due to missing privileges. In that case, IDEasy will create a | ||
| * hard link as an alternative (file-only, same volume) to avoid the Git-Bash behavior of silently copying files. | ||
| */ | ||
| public final class LnCommandlet extends Commandlet { | ||
|
|
||
| /** Grammar token {@code -s} (optional). */ | ||
| public final FlagProperty symbolic; | ||
|
|
||
| /** Grammar token {@code -r} (optional). */ | ||
| public final FlagProperty relative; | ||
|
|
||
| /** The source path to link to. */ | ||
| public final PathProperty source; | ||
|
|
||
| /** The target path (the created link). */ | ||
| public final PathProperty link; | ||
|
|
||
| /** | ||
| * The constructor. | ||
| * | ||
| * @param context the {@link IdeContext}. | ||
| */ | ||
| public LnCommandlet(IdeContext context) { | ||
|
|
||
| super(context); | ||
| addKeyword(getName()); | ||
|
|
||
| this.symbolic = add(new FlagProperty("--symbolic", false, "-s")); | ||
| this.relative = add(new FlagProperty("--relative", false, "-r")); | ||
| this.source = add(new PathProperty("", true, "source", true)); | ||
| this.link = add(new PathProperty("", true, "link", false)); | ||
| } | ||
|
|
||
| @Override | ||
| public String getName() { | ||
|
|
||
| return "ln"; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isIdeRootRequired() { | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isIdeHomeRequired() { | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean isWriteLogFile() { | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| protected void doRun() { | ||
|
|
||
| Path cwd = this.context.getCwd(); | ||
| if (cwd == null) { | ||
| throw new CliException("Missing current working directory!"); | ||
| } | ||
|
|
||
| Path sourcePath = cwd.resolve(this.source.getValue()).normalize(); | ||
| Path linkPath = cwd.resolve(this.link.getValue()).normalize(); | ||
| boolean relative = this.relative.isTrue(); | ||
|
|
||
| if (!Files.exists(sourcePath)) { | ||
| throw new CliException("Source does not exist: " + sourcePath); | ||
| } | ||
|
|
||
| PathLinkType linkType = this.symbolic.isTrue() ? PathLinkType.SYMBOLIC_LINK : PathLinkType.HARD_LINK; | ||
| this.context.getFileAccess().link(sourcePath, linkPath, relative, linkType); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
KarimALotfy marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|
KarimALotfy marked this conversation as resolved.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.