Skip to content

Add icd command #778

@hohwille

Description

@hohwille

As a IDEasy power user, I want to have advanced support for switching directories, projects and environments so that I gain efficiency during development.

The idea is to introduce a new command icd additionally to ide.
This will be an IDEasy variant of the standard cd command but with the following features:

  • whenever I changed a directory with icd, I do not have to type ide again to update my environment variables.
  • when I call icd without arguments, I will go to $IDE_HOME (instead of $HOME when calling cd). In case I am not in an IDEasy project (and have not set IDE_HOME), I will go to $IDE_ROOT.
  • when I call icd -p «project» I directly jump to that project (cd $IDE_ROOT/«project» && ide)
  • when I call icd -w [«workspace»] I directly go to the specified «workspace». The default is main if omitted. If I am not in an IDE project, this command will fail.
  • when I call `icd

Advanced features (might come in a later PR):

  • when I call icd -m [«module»] I directly go to the specified «module» in my current project. That means if I am in a maven, gradle, npm, or yarn project, I directly go to the specified module. If I omit the module name I go to the current module I am in so if I am in «module»/src/main/java/com/devonfw/tools/ide I go to «module» (cd ../../../../../../.. && ide). When I call icd -m / I go to the top-level module (project root). This feature will be rather tricky - to support multiple build systems we need some flexibility. For «module» we should always support artifactId in case of a maven/gradle project but also the module directory name if unique. In order to get the entire list of modules (Map from artifactId as String to Path) quite some parsing might be required so maybe we need caching to better support this feature efficiently. The basic approach is to traverse directories upwards until the first pom.xml, build.gradle[.kts], or package.json is found. This way icd -m and icd -m / can be implemented without parsing any of these files.
  • I want to have autocompletion for icd so icd -p TAB will suggest me all available projects (and not _ide).

ATTENTION: IMHO it makes sense to first implement #779 before starting with this story since the refactoring will make it easier to add icd and otherwise both stories might cause conflicts if developed in parallel.

Implementation hint: I would suggest to implement icd in BASH.
Please note that no sophisticated CLI parser needs to be implemented in BASH: You cannot combine any of the options like -p, -w, -m, etc. Also you cannot enter directories called -p with icd and there is no need to support -- since you can use regular cd command for such crazy edge-cases.

Metadata

Metadata

Assignees

Labels

CLIIDEasy command-line-interface (parsing args, etc.)bashbash, zsh, git-bash (integration, scripts)enhancementNew feature or request

Projects

Status

✅ Done

Relationships

None yet

Development

No branches or pull requests

Issue actions