-
Notifications
You must be signed in to change notification settings - Fork 92
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
feat: app commands #868
Open
yevheniyJ
wants to merge
6
commits into
main
Choose a base branch
from
app-command
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
feat: app commands #868
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
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 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
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
|
@@ -476,6 +476,25 @@ crowdin.project.add.source-language=Defines the source language. English by defa | |||||||||
crowdin.project.add.public=Defines whether the project is public. Private by default | ||||||||||
crowdin.project.add.string-based=Defines whether the project is string-based | ||||||||||
|
||||||||||
# CROWDIN APP COMMAND | ||||||||||
crowdin.app.usage.description=Manage apps | ||||||||||
crowdin.app.usage.customSynopsis=@|fg(green) crowdin app|@ [SUBCOMMAND] [CONFIG OPTIONS] [OPTIONS] | ||||||||||
|
||||||||||
# CROWDIN APP LIST | ||||||||||
crowdin.app.list.usage.description=List apps | ||||||||||
crowdin.app.list.usage.customSynopsis=@|fg(green) crowdin app list|@ [CONFIG OPTIONS] [OPTIONS] | ||||||||||
|
||||||||||
# CROWDIN APP INSTALL | ||||||||||
crowdin.app.install.usage.description=Install the application | ||||||||||
crowdin.app.install.usage.customSynopsis=@|fg(green) crowdin app install|@ <identifier> [CONFIG OPTIONS] [OPTIONS] | ||||||||||
crowdin.app.install.identifier=Application identifier. You can find it on Crowdin Store | ||||||||||
|
||||||||||
# CROWDIN APP UNINSTALL | ||||||||||
crowdin.app.uninstall.usage.description=Uninstall the application | ||||||||||
crowdin.app.uninstall.usage.customSynopsis=@|fg(green) crowdin app uninstall|@ <identifier> [CONFIG OPTIONS] [OPTIONS] | ||||||||||
crowdin.app.uninstall.identifier=Application identifier | ||||||||||
crowdin.app.uninstall.force=Force to delete application installation | ||||||||||
|
||||||||||
error.collect_project_info=Failed to collect project info. Please contact our support team for help | ||||||||||
error.no_sources=No sources found for '%s' pattern. Check the source paths in your configuration file | ||||||||||
error.only_enterprise=Operation is available only for Crowdin Enterprise | ||||||||||
|
@@ -521,6 +540,7 @@ error.file_not_exists=Project doesn't contain the '%s' file | |||||||||
error.file_required=The '--file' parameter is required for this type of project | ||||||||||
error.dir_not_exists=Project doesn't contain the '%s' directory | ||||||||||
error.branch_not_exists=Project doesn't contain the '%s' branch | ||||||||||
error.application_not_found=Application with identifier '%s' doesn't exist in Crowdin Store | ||||||||||
error.source_string_no_edit=Specify some parameters to edit the string | ||||||||||
error.branch_no_edit=Specify some parameters to edit the branch | ||||||||||
error.unexpected_response=Unexpected response from %s: %s | ||||||||||
|
@@ -771,6 +791,10 @@ message.label.list_empty=No labels found | |||||||||
message.label.already_exists=Label '%s' already exists in the project | ||||||||||
message.label.deleted=@|green Label '%s' deleted successfully|@ | ||||||||||
|
||||||||||
message.application.list=@|yellow %s|@ @|green %s|@ | ||||||||||
message.application.uninstall=@|green Application %s was uninstalled|@ | ||||||||||
message.application.install=@|green Application %s was installed|@ | ||||||||||
Comment on lines
+795
to
+796
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
|
||||||||||
message.delete_obsolete.obsolete_file_delete='%s' file was deleted | ||||||||||
message.delete_obsolete.obsolete_directory_delete=No obsolete files were found | ||||||||||
message.delete_obsolete.no_obsolete_files_found='%s' directory was deleted | ||||||||||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.