<commit_before>/*
 * Copyright (c) 2002-2009 "Neo Technology,"
 *     Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 * 
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.neo4j.impl.shell;

import java.io.Serializable;
import java.rmi.RemoteException;
import org.neo4j.api.core.NeoService;
import org.neo4j.api.core.Transaction;
import org.neo4j.impl.shell.apps.Cd;
import org.neo4j.impl.shell.apps.Gsh;
import org.neo4j.impl.shell.apps.Jsh;
import org.neo4j.impl.shell.apps.Ls;
import org.neo4j.impl.shell.apps.Mkrel;
import org.neo4j.impl.shell.apps.Mv;
import org.neo4j.impl.shell.apps.Pwd;
import org.neo4j.impl.shell.apps.Rm;
import org.neo4j.impl.shell.apps.Rmrel;
import org.neo4j.impl.shell.apps.Set;
import org.neo4j.impl.shell.apps.Trav;
import org.neo4j.util.shell.AbstractClient;
import org.neo4j.util.shell.BashVariableInterpreter;
import org.neo4j.util.shell.Session;
import org.neo4j.util.shell.ShellException;
import org.neo4j.util.shell.ShellServer;
import org.neo4j.util.shell.SimpleAppServer;
import org.neo4j.util.shell.BashVariableInterpreter.Replacer;
import org.neo4j.util.shell.apps.Help;

/**
 * A {@link ShellServer} which contains common methods to use with neo.
 */
public class NeoShellServer extends SimpleAppServer
{
    private NeoService neo;
    private BashVariableInterpreter bashInterpreter;

    /**
     * @param neo
     *            the {@link NeoService} instance to use with the shell server.
     * @throws RemoteException
     *             if an RMI error occurs.
     */
    public NeoShellServer( NeoService neo ) throws RemoteException
    {
        super();
        addNeoApps();
        this.neo = neo;
        this.bashInterpreter = new BashVariableInterpreter();
        this.bashInterpreter.addReplacer( "W", new WorkingDirReplacer() );
        this.setProperty( AbstractClient.PROMPT_KEY, "neo-sh \\W$ " );
        this.setProperty( AbstractClient.TITLE_KEYS_KEY,
            ".*name.*,.*title.*" );
        this.setProperty( AbstractClient.TITLE_MAX_LENGTH, "40" );
    }

    @Override
    public String welcome()
    {
        return "Welcome to NeoShell\n" + Help.getHelpString( this );
    }
    
    private void addNeoApps()
    {
        addApp( Cd.class );<commit_msg>Added ability to start a local client in read-only mode so that it won't grab a lock on the store, making other applications able to use the same store as well<commit_after>/*
 * Copyright (c) 2002-2009 "Neo Technology,"
 *     Network Engine for Objects in Lund AB [http://neotechnology.com]
 *
 * This file is part of Neo4j.
 * 
 * Neo4j is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as
 * published by the Free Software Foundation, either version 3 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.neo4j.impl.shell;

import java.io.Serializable;
import java.rmi.RemoteException;

import org.neo4j.api.core.EmbeddedReadOnlyNeo;
import org.neo4j.api.core.NeoService;
import org.neo4j.api.core.Transaction;
import org.neo4j.impl.shell.apps.Cd;
import org.neo4j.impl.shell.apps.Gsh;
import org.neo4j.impl.shell.apps.Jsh;
import org.neo4j.impl.shell.apps.Ls;
import org.neo4j.impl.shell.apps.Mkrel;
import org.neo4j.impl.shell.apps.Mv;
import org.neo4j.impl.shell.apps.Pwd;
import org.neo4j.impl.shell.apps.Rm;
import org.neo4j.impl.shell.apps.Rmrel;
import org.neo4j.impl.shell.apps.Set;
import org.neo4j.impl.shell.apps.Trav;
import org.neo4j.util.shell.AbstractClient;
import org.neo4j.util.shell.BashVariableInterpreter;
import org.neo4j.util.shell.Session;
import org.neo4j.util.shell.ShellException;
import org.neo4j.util.shell.ShellServer;
import org.neo4j.util.shell.SimpleAppServer;
import org.neo4j.util.shell.BashVariableInterpreter.Replacer;
import org.neo4j.util.shell.apps.Help;

/**
 * A {@link ShellServer} which contains common methods to use with neo.
 */
public class NeoShellServer extends SimpleAppServer
{
    private NeoService neo;
    private BashVariableInterpreter bashInterpreter;

    /**
     * @param neo
     *            the {@link NeoService} instance to use with the shell server.
     * @throws RemoteException
     *             if an RMI error occurs.
     */
    public NeoShellServer( NeoService neo ) throws RemoteException
    {
        super();
        addNeoApps();
        this.neo = neo;
        this.bashInterpreter = new BashVariableInterpreter();
        this.bashInterpreter.addReplacer( "W", new WorkingDirReplacer() );
        this.setProperty( AbstractClient.PROMPT_KEY, getNeoShellPrompt() );
        this.setProperty( AbstractClient.TITLE_KEYS_KEY,
            ".*name.*,.*title.*" );
        this.setProperty( AbstractClient.TITLE_MAX_LENGTH, "40" );
    }
    
    protected String getNeoShellPrompt()
    {
        String name = "neo-sh";
        if ( this.neo instanceof EmbeddedReadOnlyNeo )
        {
            name += "[readonly]";
        }
        name += " \\W$ ";
        return name;
    }

    @Override
    public String welcome()
    {
        return "Welcome to NeoShell\n" + Help.getHelpString( this );
    }
    
    private void addNeoApps()
    {
        addApp( Cd.class );
{'fraction_non_alphanumeric': 0.10180309558002235, 'fraction_numerical': 0.011329184617839477, 'mean_word_length': 3.229419703103914, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6437288', 'n_tokens_mistral': 2026, 'n_tokens_neox': 1950, 'n_words': 551}