• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 9808947434

05 Jul 2024 01:16PM UTC coverage: 61.755% (-0.04%) from 61.798%
9808947434

push

github

web-flow
#396: Display the tools help output on 'ide help <tool>'  (#434)

1987 of 3535 branches covered (56.21%)

Branch coverage included in aggregate %.

5276 of 8226 relevant lines covered (64.14%)

2.81 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

5.71
cli/src/main/java/com/devonfw/tools/ide/tool/aws/Aws.java
1
package com.devonfw.tools.ide.tool.aws;
2

3
import com.devonfw.tools.ide.common.Tag;
4
import com.devonfw.tools.ide.context.IdeContext;
5
import com.devonfw.tools.ide.environment.EnvironmentVariables;
6
import com.devonfw.tools.ide.environment.EnvironmentVariablesType;
7
import com.devonfw.tools.ide.io.FileAccess;
8
import com.devonfw.tools.ide.nls.NlsBundle;
9
import com.devonfw.tools.ide.process.ProcessContext;
10
import com.devonfw.tools.ide.tool.LocalToolCommandlet;
11

12
import java.io.IOException;
13
import java.nio.file.Path;
14
import java.util.Set;
15

16
/**
17
 * {@link LocalToolCommandlet} for <a href="https://docs.aws.amazon.com/cli/">AWS CLI</a> (Amazon Web Services Command
18
 * Line Interface).
19
 */
20
public class Aws extends LocalToolCommandlet {
21

22
  /**
23
   * The constructor.
24
   *
25
   * @param context the {@link IdeContext}.
26
   */
27
  public Aws(IdeContext context) {
28

29
    super(context, "aws", Set.of(Tag.CLOUD));
6✔
30
  }
1✔
31

32
  @Override
33
  public void postInstall() {
34

35
    super.postInstall();
×
36
    EnvironmentVariables variables = this.context.getVariables();
×
37
    EnvironmentVariables typeVariables = variables.getByType(EnvironmentVariablesType.CONF);
×
38
    Path awsConfigDir = this.context.getConfPath().resolve("aws");
×
39
    this.context.getFileAccess().mkdirs(awsConfigDir);
×
40
    Path awsConfigFile = awsConfigDir.resolve("config");
×
41
    Path awsCredentialsFile = awsConfigDir.resolve("credentials");
×
42
    typeVariables.set("AWS_CONFIG_FILE", awsConfigFile.toString(), true);
×
43
    typeVariables.set("AWS_SHARED_CREDENTIALS_FILE", awsCredentialsFile.toString(), true);
×
44
    typeVariables.save();
×
45
  }
×
46

47
  protected void postExtract(Path extractedDir) {
48

49
    if (this.context.getSystemInfo().isLinux()) {
×
50
      // running the install-script that aws shipped
51
      ProcessContext pc = this.context.newProcess();
×
52
      Path linuxInstallScript = extractedDir.resolve("install");
×
53
      pc.executable(linuxInstallScript);
×
54
      pc.addArgs("-i", extractedDir.toString(), "-b", extractedDir.toString());
×
55
      pc.run();
×
56

57
      // The install-script that aws ships creates symbolic links to binaries but using absolute paths.
58
      // Since the current process happens in a temporary dir, these links wouldn't be valid after moving the
59
      // installation files to the target dir. So the absolute paths are replaced by relative ones.
60
      FileAccess fileAccess = this.context.getFileAccess();
×
61
      for (String file : new String[] { "aws", "aws_completer", "v2/current" }) {
×
62
        Path link = extractedDir.resolve(file);
×
63
        try {
64
          fileAccess.symlink(link.toRealPath(), link, true);
×
65
        } catch (IOException e) {
×
66
          throw new RuntimeException(
×
67
              "Failed to replace absolute link (" + link + ") provided by AWS install script with relative link.", e);
68
        }
×
69
      }
70
      fileAccess.delete(linuxInstallScript);
×
71
      fileAccess.delete(extractedDir.resolve("dist"));
×
72
    }
73
  }
×
74

75
  @Override
76
  public void printHelp(NlsBundle bundle) {
77

78
    this.context.info("To get detailed help about the usage of the AWS CLI, use \"aws help\"");
×
79
  }
×
80

81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc