# Path: px/px_commandline.py
# LINUX_KERNEL_PROC = re.compile(u"^\\[[^/ ]+/?[^/ ]+\\]$")
# OSX_PARENTHESIZED_PROC = re.compile(u"^\\([^()]+\\)$")
# PERL_BIN = re.compile(u"^perl[.0-9]*$")
#     IGNORE_SWITCHES = [
#         "-b",
#         "-bb",
#         "-B",
#         "-d",
#         "-E",
#         "-i",
#         "-O",
#         "-OO",
#         "-R",
#         "-s",
#         "-S",
#         "-t",
#         "-tt",
#         "-u",
#         "-v",
#         "-Werror",
#         "-x",
#         "-3",
#     ]
# def to_array(commandline):
# def is_human_friendly(command):
# def get_app_name_prefix(commandline):
# def try_clarify_electron(commandline):
# def get_command(commandline):
# def get_python_command(commandline):
# def get_sudo_command(commandline):
# def prettify_fully_qualified_java_class(class_name):
# def get_java_command(commandline):
# def get_generic_script_command(commandline, ignore_switches=[]):


import os
from px import px_commandline
    assert px_commandline.get_command("python -m") == "python"
    assert px_commandline.get_command("python -m   ") == "python"
    assert px_commandline.get_command("python -m -u") == "python"
    assert px_commandline.get_command("python    ") == "python"


def test_get_command_java():
    assert px_commandline.get_command("java") == "java"
    assert px_commandline.get_command("java -version") == "java"
    assert px_commandline.get_command("java -help") == "java"

    assert px_commandline.get_command("java SomeClass") == "SomeClass"
    assert px_commandline.get_command("java x.y.SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -jar flaska.jar") == "flaska.jar"
    assert px_commandline.get_command("java -jar /a/b/flaska.jar") == "flaska.jar"

    # Special handling of class name "Main"
    assert px_commandline.get_command("java a.b.c.Main") == "c.Main"

    # We should ignore certain command line parameters
    assert px_commandline.get_command("java -server SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -Xwhatever SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -Dwhatever SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -cp /a/b/c SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -classpath /a/b/c SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -eahej SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -dahej SomeClass") == "SomeClass"

    # Tests for invalid command lines
    assert px_commandline.get_command("java -cp /a/b/c") == "java"

# Path: px/px_commandline.py
# LINUX_KERNEL_PROC = re.compile(u"^\\[[^/ ]+/?[^/ ]+\\]$")
# OSX_PARENTHESIZED_PROC = re.compile(u"^\\([^()]+\\)$")
# PERL_BIN = re.compile(u"^perl[.0-9]*$")
#     IGNORE_SWITCHES = [
#         "-b",
#         "-bb",
#         "-B",
#         "-d",
#         "-E",
#         "-i",
#         "-O",
#         "-OO",
#         "-R",
#         "-s",
#         "-S",
#         "-t",
#         "-tt",
#         "-u",
#         "-v",
#         "-Werror",
#         "-x",
#         "-3",
#     ]
# def to_array(commandline):
# def is_human_friendly(command):
# def get_app_name_prefix(commandline):
# def try_clarify_electron(commandline):
# def get_command(commandline):
# def get_python_command(commandline):
# def get_sudo_command(commandline):
# def prettify_fully_qualified_java_class(class_name):
# def get_java_command(commandline):
# def get_generic_script_command(commandline, ignore_switches=[]):


# Path: tests/px_commandline_test.py
import os
from px import px_commandline

    assert px_commandline.get_command("python -m") == "python"
    assert px_commandline.get_command("python -m   ") == "python"
    assert px_commandline.get_command("python -m -u") == "python"
    assert px_commandline.get_command("python    ") == "python"


def test_get_command_java():
    assert px_commandline.get_command("java") == "java"
    assert px_commandline.get_command("java -version") == "java"
    assert px_commandline.get_command("java -help") == "java"

    assert px_commandline.get_command("java SomeClass") == "SomeClass"
    assert px_commandline.get_command("java x.y.SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -jar flaska.jar") == "flaska.jar"
    assert px_commandline.get_command("java -jar /a/b/flaska.jar") == "flaska.jar"

    # Special handling of class name "Main"
    assert px_commandline.get_command("java a.b.c.Main") == "c.Main"

    # We should ignore certain command line parameters
    assert px_commandline.get_command("java -server SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -Xwhatever SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -Dwhatever SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -cp /a/b/c SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -classpath /a/b/c SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -eahej SomeClass") == "SomeClass"
    assert px_commandline.get_command("java -dahej SomeClass") == "SomeClass"

    # Tests for invalid command lines
    assert px_commandline.get_command("java -cp /a/b/c") == "java"

    assert px_commandline.get_command("java  ") == "java"