Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[sarlc] Add the command line options for running the extra-language g…
…enerators. Signed-off-by: Stéphane Galland <galland@arakhne.org>
- Loading branch information
1 parent
a283dfe
commit 456ba7e
Showing
17 changed files
with
303 additions
and
26 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
89 changes: 89 additions & 0 deletions
89
products/sarlc/src/main/java/io/sarl/lang/sarlc/commands/ExtraLanguageListCommand.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,89 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2018 the original authors or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sarl.lang.sarlc.commands; | ||
|
||
import java.util.Set; | ||
import java.util.TreeSet; | ||
|
||
import com.google.inject.Provider; | ||
import io.bootique.cli.Cli; | ||
import io.bootique.command.CommandOutcome; | ||
import io.bootique.command.CommandWithMetadata; | ||
import io.bootique.log.BootLogger; | ||
import io.bootique.meta.application.CommandMetadata; | ||
|
||
import io.sarl.lang.extralanguage.IExtraLanguageContribution; | ||
import io.sarl.lang.extralanguage.IExtraLanguageContributions; | ||
|
||
/** | ||
* Command for showing up the list of extra languages that are available on the classpath. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.8 | ||
*/ | ||
public class ExtraLanguageListCommand extends CommandWithMetadata { | ||
|
||
/** Name of the option for enabling the progress bar. | ||
*/ | ||
public static final String EXTRA_LANGUAGE_LIST_OPTION_NAME = "printgenerators"; //$NON-NLS-1$ | ||
|
||
/** Name of the option for enabling the progress bar. | ||
*/ | ||
public static final char EXTRA_LANGUAGE_LIST_OPTION_SHORT_NAME = 'G'; | ||
|
||
private final BootLogger bootLogger; | ||
|
||
private final Provider<IExtraLanguageContributions> contributions; | ||
|
||
/** Constructor. | ||
* | ||
* @param bootLogger the logger. | ||
* @param contributions the provider of the extra-language contributions. | ||
*/ | ||
public ExtraLanguageListCommand(BootLogger bootLogger, Provider<IExtraLanguageContributions> contributions) { | ||
super(CommandMetadata | ||
.builder(ExtraLanguageListCommand.class) | ||
.description(Messages.ExtraLanguageListCommand_0) | ||
.name(EXTRA_LANGUAGE_LIST_OPTION_NAME) | ||
.shortName(EXTRA_LANGUAGE_LIST_OPTION_SHORT_NAME)); | ||
this.bootLogger = bootLogger; | ||
this.contributions = contributions; | ||
} | ||
|
||
@Override | ||
public CommandOutcome run(Cli cli) { | ||
final Set<String> identifiers = new TreeSet<>(); | ||
for (final IExtraLanguageContribution contribution : this.contributions.get().getContributions()) { | ||
identifiers.addAll(contribution.getIdentifiers()); | ||
} | ||
final StringBuilder text = new StringBuilder(); | ||
for (final String id : identifiers) { | ||
text.append(id).append("\n"); //$NON-NLS-1$ | ||
} | ||
this.bootLogger.stdout(text.toString()); | ||
return CommandOutcome.succeeded(); | ||
} | ||
|
||
} |
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
64 changes: 64 additions & 0 deletions
64
...rlc/src/main/java/io/sarl/lang/sarlc/modules/commands/ExtraLanguageListCommandModule.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,64 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2018 the original authors or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sarl.lang.sarlc.modules.commands; | ||
|
||
import static io.bootique.BQCoreModule.extend; | ||
|
||
import com.google.inject.AbstractModule; | ||
import com.google.inject.Provider; | ||
import com.google.inject.Provides; | ||
import com.google.inject.Singleton; | ||
import io.bootique.log.BootLogger; | ||
|
||
import io.sarl.lang.extralanguage.IExtraLanguageContributions; | ||
import io.sarl.lang.sarlc.commands.ExtraLanguageListCommand; | ||
|
||
/** Module for the command for printing out the available extra-language generators. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.8 | ||
*/ | ||
public class ExtraLanguageListCommandModule extends AbstractModule { | ||
|
||
@Override | ||
protected void configure() { | ||
extend(binder()).addCommand(ExtraLanguageListCommand.class); | ||
} | ||
|
||
/** Provide the command for displaying the available extra-language generators. | ||
* | ||
* @param bootLogger the logger. | ||
* @param contributions the provider of the extra-language contributions. | ||
* @return the command. | ||
*/ | ||
@SuppressWarnings("static-method") | ||
@Provides | ||
@Singleton | ||
public ExtraLanguageListCommand provideExtraLanguageListCommand(BootLogger bootLogger, | ||
Provider<IExtraLanguageContributions> contributions) { | ||
return new ExtraLanguageListCommand(bootLogger, contributions); | ||
} | ||
|
||
} |
53 changes: 53 additions & 0 deletions
53
...main/java/io/sarl/lang/sarlc/modules/commands/ExtraLanguageListCommandModuleProvider.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,53 @@ | ||
/* | ||
* $Id$ | ||
* | ||
* SARL is an general-purpose agent programming language. | ||
* More details on http://www.sarl.io | ||
* | ||
* Copyright (C) 2014-2018 the original authors or authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.sarl.lang.sarlc.modules.commands; | ||
|
||
import com.google.inject.Module; | ||
import io.bootique.BQModule; | ||
import io.bootique.BQModuleProvider; | ||
|
||
/** Provider of the module for printing out the available extra-language generators. | ||
* | ||
* @author $Author: sgalland$ | ||
* @version $FullVersion$ | ||
* @mavengroupid $GroupId$ | ||
* @mavenartifactid $ArtifactId$ | ||
* @since 0.8 | ||
*/ | ||
public class ExtraLanguageListCommandModuleProvider implements BQModuleProvider { | ||
|
||
@Override | ||
public Module module() { | ||
return new ExtraLanguageListCommandModule(); | ||
} | ||
|
||
@Override | ||
public BQModule.Builder moduleBuilder() { | ||
return BQModule | ||
.builder(module()) | ||
.overrides(overrides()) | ||
.providerName(name()) | ||
.configs(configs()) | ||
.description(Messages.ExtraLanguageListCommandModuleProvider_0); | ||
} | ||
|
||
} |
Oops, something went wrong.