Examples of IO


Examples of org.sonatype.gshell.command.IO

{
    @Override
    protected Object execute(final CommandContext context, final NexusClient client) throws Exception {
        assert context != null;
        assert client != null;
        IO io = context.getIo();

        io.println("Requesting start..."); // TODO: i18n
       
        client.ext(AdminClient.class).start();

        StatusResource status = client.ext(BasicClient.class).status();
        io.println("State: {}", status.getState()); // TODO: i18n

        return Result.SUCCESS;
    }
View Full Code Here

Examples of org.sonatype.gshell.command.IO

   
    @Override
    protected Object execute(final CommandContext context, final NexusClient client) throws Exception {
        assert context != null;
        assert client != null;
        IO io = context.getIo();

        client.ext(StagingClient.class).drop(profileId, repositoryId);

        return Result.SUCCESS;
    }
View Full Code Here

Examples of org.sonatype.gshell.command.IO

    @Override
    protected Object execute(final CommandContext context, final NexusClient client) throws Exception {
        assert context != null;
        assert client != null;
        IO io = context.getIo();

        client.ext(StagingClient.class).close(profileId, repositoryId, description);

        return Result.SUCCESS;
    }
View Full Code Here

Examples of org.sonatype.gshell.command.IO

{
    @Override
    protected Object execute(final CommandContext context, final NexusClient client) throws Exception {
        assert context != null;
        assert client != null;
        IO io = context.getIo();

        List<StagingProfile> profiles = client.ext(StagingClient.class).listProfiles();

        for (StagingProfile profile : profiles) {
            io.println("Id: {}", profile.getId());
            io.println("  Name: {}", profile.getName());
            io.println("  URI: {}", profile.getResourceURI());
        }

        return profiles;
    }
View Full Code Here

Examples of org.sonatype.gshell.command.IO

    @Override
    protected Object execute(final CommandContext context, final NexusClient client) throws Exception {
        assert context != null;
        assert client != null;
        IO io = context.getIo();

        client.ext(StagingClient.class).promote(profileId, repositoryId, targetRepositoryId);

        return Result.SUCCESS;
    }
View Full Code Here

Examples of org.sonatype.gshell.command.IO

    @Override
    protected Object execute(final CommandContext context, final NexusClient client) throws Exception {
        assert context != null;
        assert client != null;
        IO io = context.getIo();

        List<StagingProfileRepository> repos = client.ext(StagingClient.class).listRepositories(profileId);

        for (StagingProfileRepository repo : repos) {
            io.println("ID: {}", repo.getRepositoryId());
            io.println("  Profile ID: {}", repo.getProfileId());
            io.println("  Description: {}", repo.getDescription());
            io.println("  Type: {}", repo.getType());
            io.println("  User ID: {}", repo.getUserId());
        }

        return repos;
    }
View Full Code Here

Examples of org.sonatype.gshell.command.IO

        this.plexus = plexus;
    }

    public Object execute(final CommandContext context) throws Exception {
        assert context != null;
        IO io = context.getIo();

        new FileAssert(repository).exists().isDirectory();

        RepositoryCrawler crawler = plexus.lookup(RepositoryCrawler.class);
View Full Code Here

Examples of org.sonatype.gshell.command.IO

        return this;
    }

    public Object execute(final CommandContext context) throws Exception {
        assert context != null;
        IO io = context.getIo();
        Variables vars = context.getVariables();

        io.println("Creating archetype from: {}", pomFile.getAbsoluteFile()); // TODO: i18n

        MavenProject project = buildProject(context);
        log.debug("Built project: {}", project);

        log.debug("Configuring");
        ArchetypeCreationConfigurator configurator = plexus.lookup(ArchetypeCreationConfigurator.class);
        Properties config = configurator.configureArchetypeCreation(project, !batch, props, null, languages);

        RepositorySystem rsys = plexus.lookup(RepositorySystem.class);

        ArchetypeCreationRequest request = new ArchetypeCreationRequest()
            .setProject(project)
            .setProperties(config)
            .setLanguages(languages)
            .setFilteredExtensions(filteredExtensions)
            .setPreserveCData(preserveCDATA)
            .setKeepParent(keepParent)
            .setPartialArchetype(partial)
            .setLocalRepository(rsys.createDefaultLocalRepository())
            .setPackageName(packageName);

        if (registryFile == null) {
            File dir = vars.get(SHELL_USER_HOME, File.class);
            registryFile = new File(dir, ".m2/archetype.xml");
        }
        request.setArchetypeRegistryFile(registryFile);

        if (outputDirectory != null) {
            request.setOutputDirectory(outputDirectory);
        }
        else {
            // HACK: Default dir is not rooted
            System.setProperty("user.dir", vars.get(SHELL_USER_DIR, File.class).getAbsolutePath());
        }

        log.debug("Creating archetype");
        ArchetypeManager archetypeManager = plexus.lookup(ArchetypeManager.class);
        ArchetypeCreationResult result = archetypeManager.createArchetypeFromProject(request);

        if (result.getCause() != null) {
            throw result.getCause();
        }

        // HACK: Prompter has some issues, so add a newline
        io.out.println();

        io.println("Archetype created in: {}", request.getOutputDirectory().getAbsolutePath()); // TODO: i18n

        return Result.SUCCESS;
    }
View Full Code Here

Examples of org.sonatype.gshell.command.IO

        this.plexus = plexus;
    }

    public Object execute(final CommandContext context) throws Exception {
        assert context != null;
        IO io = context.getIo();
        Variables vars = context.getVariables();

        RepositorySystem rsys = plexus.lookup(RepositorySystem.class);
        ArchetypeGenerationRequest request = new ArchetypeGenerationRequest()
            .setLocalRepository(rsys.createDefaultLocalRepository())
            .setRemoteArtifactRepositories(Collections.singletonList(rsys.createDefaultRemoteRepository()));

        if (outputDirectory == null) {
            outputDirectory = new File(vars.get(SHELL_USER_DIR, String.class));
        }
        request.setOutputDirectory(outputDirectory.getAbsolutePath());

        if (archetypeId != null) {
            String[] items = archetypeId.split(":", 3);
            if (items.length != 3) {
                io.error("Invalid archetype id: {}", archetypeId); // TODO: i18n
                return Result.FAILURE;
            }

            request.setArchetypeGroupId(items[0])
                .setArchetypeArtifactId(items[1])
View Full Code Here

Examples of org.sonatype.gshell.command.IO

    @Override
    protected Object execute(final CommandContext context, final NexusClient client) throws Exception {
        assert context != null;
        assert client != null;
        IO io = context.getIo();

        //
        // TODO: Prompt for server/instance/username/password if not given, or --interactive is configured,
        //       need to bring back the prompt helper components from gshell 1.x
        //

        log.debug("Opening");

        client.open(server, instance);
   
        if (username != null) {
            log.debug("Logging in");

            AuthenticationLoginResource detail = client.login(username, password);
            AuthenticationClientPermissions perms = detail.getClientPermissions();

            if (perms.isLoggedIn()) {
                // TODO: Add colors

                io.println("User: {}", perms.getLoggedInUsername()); // TODO: i18n
                io.println("Source: {}", perms.getLoggedInUserSource()); // TODO: i18n

                // TODO: Add more details
            }
            else {
                io.error("Authentication failed"); // TODO: i18n
                return Result.FAILURE;
            }
        }

        // Try to fetch something before we bind into context
        StatusResource status = client.ext(BasicClient.class).status();

        context.getVariables().set(NexusClient.class, client);

        io.println("Connected to: {} ({} v{})", status.getBaseUrl(), status.getAppName(), status.getApiVersion()); // TODO: i18n

        return client;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.