-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
544 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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 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
27 changes: 27 additions & 0 deletions
27
src/main/java/com/crowdin/cli/commands/actions/AppInstallAction.java
This file contains 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,27 @@ | ||
package com.crowdin.cli.commands.actions; | ||
|
||
import com.crowdin.cli.client.ProjectClient; | ||
import com.crowdin.cli.commands.NewAction; | ||
import com.crowdin.cli.commands.Outputter; | ||
import com.crowdin.cli.commands.picocli.ExitCodeExceptionMapper; | ||
import com.crowdin.cli.properties.ProjectProperties; | ||
import com.crowdin.cli.utils.console.ExecutionStatus; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import static com.crowdin.cli.BaseCli.RESOURCE_BUNDLE; | ||
|
||
@RequiredArgsConstructor | ||
class AppInstallAction implements NewAction<ProjectProperties, ProjectClient> { | ||
|
||
private final String id; | ||
|
||
@Override | ||
public void act(Outputter out, ProjectProperties pb, ProjectClient client) { | ||
var manifestUrl = client.findManifestUrl(id); | ||
if (manifestUrl.isEmpty()) { | ||
throw new ExitCodeExceptionMapper.NotFoundException(String.format(RESOURCE_BUNDLE.getString("error.application_not_found"), this.id)); | ||
} | ||
client.installApplication(manifestUrl.get()); | ||
out.println(ExecutionStatus.OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.application.install"), id))); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/main/java/com/crowdin/cli/commands/actions/AppListAction.java
This file contains 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,29 @@ | ||
package com.crowdin.cli.commands.actions; | ||
|
||
import com.crowdin.cli.client.ProjectClient; | ||
import com.crowdin.cli.commands.NewAction; | ||
import com.crowdin.cli.commands.Outputter; | ||
import com.crowdin.cli.properties.ProjectProperties; | ||
|
||
import static com.crowdin.cli.BaseCli.RESOURCE_BUNDLE; | ||
|
||
class AppListAction implements NewAction<ProjectProperties, ProjectClient> { | ||
private final boolean plainView; | ||
|
||
public AppListAction(boolean plainView) { | ||
this.plainView = plainView; | ||
} | ||
|
||
@Override | ||
public void act(Outputter out, ProjectProperties pb, ProjectClient client) { | ||
client | ||
.listApplications() | ||
.forEach(app -> { | ||
if (!plainView) { | ||
out.println(String.format(RESOURCE_BUNDLE.getString("message.application.list"), app.getIdentifier(), app.getName())); | ||
} else { | ||
out.println(app.getIdentifier()); | ||
} | ||
}); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
src/main/java/com/crowdin/cli/commands/actions/AppUninstallAction.java
This file contains 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,23 @@ | ||
package com.crowdin.cli.commands.actions; | ||
|
||
import com.crowdin.cli.client.ProjectClient; | ||
import com.crowdin.cli.commands.NewAction; | ||
import com.crowdin.cli.commands.Outputter; | ||
import com.crowdin.cli.properties.ProjectProperties; | ||
import com.crowdin.cli.utils.console.ExecutionStatus; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
import static com.crowdin.cli.BaseCli.RESOURCE_BUNDLE; | ||
|
||
@RequiredArgsConstructor | ||
class AppUninstallAction implements NewAction<ProjectProperties, ProjectClient> { | ||
|
||
private final String id; | ||
private final boolean force; | ||
|
||
@Override | ||
public void act(Outputter out, ProjectProperties pb, ProjectClient client) { | ||
client.uninstallApplication(id, force); | ||
out.println(ExecutionStatus.OK.withIcon(String.format(RESOURCE_BUNDLE.getString("message.application.uninstall"), id))); | ||
} | ||
} |
This file contains 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
22 changes: 22 additions & 0 deletions
22
src/main/java/com/crowdin/cli/commands/picocli/AppInstallSubcommand.java
This file contains 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,22 @@ | ||
package com.crowdin.cli.commands.picocli; | ||
|
||
import com.crowdin.cli.client.ProjectClient; | ||
import com.crowdin.cli.commands.Actions; | ||
import com.crowdin.cli.commands.NewAction; | ||
import com.crowdin.cli.properties.ProjectProperties; | ||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command( | ||
sortOptions = false, | ||
name = CommandNames.INSTALL | ||
) | ||
class AppInstallSubcommand extends ActCommandProject { | ||
|
||
@CommandLine.Parameters(descriptionKey = "crowdin.app.install.identifier") | ||
protected String identifier; | ||
|
||
@Override | ||
protected NewAction<ProjectProperties, ProjectClient> getAction(Actions actions) { | ||
return actions.installApp(identifier); | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/crowdin/cli/commands/picocli/AppListSubcommand.java
This file contains 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,26 @@ | ||
package com.crowdin.cli.commands.picocli; | ||
|
||
import com.crowdin.cli.client.ProjectClient; | ||
import com.crowdin.cli.commands.Actions; | ||
import com.crowdin.cli.commands.NewAction; | ||
import com.crowdin.cli.properties.ProjectProperties; | ||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command( | ||
name = CommandNames.LIST | ||
) | ||
class AppListSubcommand extends ActCommandProject { | ||
|
||
@Override | ||
protected NewAction<ProjectProperties, ProjectClient> getAction(Actions actions) { | ||
return actions.listApps(this.plainView); | ||
} | ||
|
||
@CommandLine.Option(names = {"--plain"}, descriptionKey = "crowdin.list.usage.plain") | ||
protected boolean plainView; | ||
|
||
@Override | ||
protected final boolean isAnsi() { | ||
return super.isAnsi() && !plainView; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/main/java/com/crowdin/cli/commands/picocli/AppUninstallSubcommand.java
This file contains 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,25 @@ | ||
package com.crowdin.cli.commands.picocli; | ||
|
||
import com.crowdin.cli.client.ProjectClient; | ||
import com.crowdin.cli.commands.Actions; | ||
import com.crowdin.cli.commands.NewAction; | ||
import com.crowdin.cli.properties.ProjectProperties; | ||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command( | ||
sortOptions = false, | ||
name = CommandNames.UNINSTALL | ||
) | ||
class AppUninstallSubcommand extends ActCommandProject { | ||
|
||
@CommandLine.Parameters(descriptionKey = "crowdin.app.uninstall.identifier") | ||
protected String identifier; | ||
|
||
@CommandLine.Option(names = {"--force"}, descriptionKey = "crowdin.app.uninstall.force", order = -2) | ||
protected boolean force; | ||
|
||
@Override | ||
protected NewAction<ProjectProperties, ProjectClient> getAction(Actions actions) { | ||
return actions.uninstallApp(identifier, force); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
src/main/java/com/crowdin/cli/commands/picocli/ApplicationSubcommand.java
This file contains 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,19 @@ | ||
package com.crowdin.cli.commands.picocli; | ||
|
||
import picocli.CommandLine; | ||
|
||
@CommandLine.Command( | ||
name = CommandNames.APP, | ||
subcommands = { | ||
AppListSubcommand.class, | ||
AppInstallSubcommand.class, | ||
AppUninstallSubcommand.class | ||
} | ||
) | ||
class ApplicationSubcommand extends HelpCommand { | ||
|
||
@Override | ||
protected CommandLine getCommand(CommandLine rootCommand) { | ||
return rootCommand.getSubcommands().get(CommandNames.APP); | ||
} | ||
} |
This file contains 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 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 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.