# Path: scripnix/pybin/hyphenate.py
# COMMAND_NAME = "hyphenate"
# 
# def hyphenate(lines, delimiter):
#     """ Return the list of lines with all non-word characters replaced by the given delimiter.
#     """
#     # Replace non-word characters by splitting the string at sequences of them and then joining the non-empty fragments together using the
#     # delimiter.
#     return [delimiter.join(w for w in NON_WORD_REGEX.split(l) if w) for l in lines]
# 
# @common_command_and_options(command_name=COMMAND_NAME)
# @click.option('--delimiter', '-d', default='-', show_default=True, help="Word delimiter character(s).")
# @click.argument('text', nargs=-1)
# def main(delimiter, text):
#     """ Translate the given text argument(s) (or use the input lines from STDIN) into the equivalent, filesystem-safe, hyphenated versions.
# 
#         The hyphenate command is part of Scripnix.
#     """
#     if text:
#         lines = text
#     else:
#         lines = sys.stdin
# 
#     for line in hyphenate(lines=lines, delimiter=delimiter):
#         click.echo(line.strip())
# 
# Path: tests/command.py
# def common_help_option(command_entry, command_name):
#     """ Test help message for both standard option switches."""
#     def version_option_switch(option_switch):
#         runner = CliRunner()
#         result = runner.invoke(command_entry, [option_switch])
#         assert result.exit_code == 0
#         match = HELP_OPTION_REGEX.match(result.output.replace("\n", ""))
#         assert match.group(1) == command_name
# 
#     version_option_switch("-h")
#     version_option_switch("--help")
# 
# def common_version_option(command_entry, command_name):
#     """ Test version message for both standard option switches."""
#     def version_option_switch(option_switch):
#         runner = CliRunner()
#         result = runner.invoke(command_entry, [option_switch])
#         assert result.exit_code == 0
#         match = VERSION_OPTION_REGEX.match(result.output.replace("\n", ""))
#         assert match.group(1) == command_name
#         assert match.group(2) == __version__
# 
#     version_option_switch("-V")
#     version_option_switch("--version")


from click.testing import CliRunner
from scripnix.pybin.hyphenate import COMMAND_NAME, hyphenate, main
from .command import common_help_option, common_version_option
import pytest
    assert lines_copy == lines


@pytest.mark.parametrize('arguments,expected', [
    ([], ""),
    (["foo"], "foo\n"),
    (["foo bar", "   bar    baz   ", "baz___bat", "  _quux_  "], "foo-bar\nbar-baz\nbaz___bat\n_quux_\n"),
])
def test_main_arguments(arguments, expected):
    runner = CliRunner()
    arguments_copy = arguments[:]
    result = runner.invoke(main, arguments)
    assert arguments_copy == arguments
    assert result.exit_code == 0
    assert result.output == expected


@pytest.mark.parametrize('stdin,expected', [
    ("", ""),
    ("foo", "foo\n"),
    ("foo bar\n   bar    baz   \nbaz___bat\n  _quux_  ", "foo-bar\nbar-baz\nbaz___bat\n_quux_\n"),
])
def test_main_stdin(stdin, expected):
    runner = CliRunner()
    result = runner.invoke(main, input=stdin)
    assert result.exit_code == 0
    assert result.output == expected


def test_version_option():

# Path: scripnix/pybin/hyphenate.py
# COMMAND_NAME = "hyphenate"
# 
# def hyphenate(lines, delimiter):
#     """ Return the list of lines with all non-word characters replaced by the given delimiter.
#     """
#     # Replace non-word characters by splitting the string at sequences of them and then joining the non-empty fragments together using the
#     # delimiter.
#     return [delimiter.join(w for w in NON_WORD_REGEX.split(l) if w) for l in lines]
# 
# @common_command_and_options(command_name=COMMAND_NAME)
# @click.option('--delimiter', '-d', default='-', show_default=True, help="Word delimiter character(s).")
# @click.argument('text', nargs=-1)
# def main(delimiter, text):
#     """ Translate the given text argument(s) (or use the input lines from STDIN) into the equivalent, filesystem-safe, hyphenated versions.
# 
#         The hyphenate command is part of Scripnix.
#     """
#     if text:
#         lines = text
#     else:
#         lines = sys.stdin
# 
#     for line in hyphenate(lines=lines, delimiter=delimiter):
#         click.echo(line.strip())
# 
# Path: tests/command.py
# def common_help_option(command_entry, command_name):
#     """ Test help message for both standard option switches."""
#     def version_option_switch(option_switch):
#         runner = CliRunner()
#         result = runner.invoke(command_entry, [option_switch])
#         assert result.exit_code == 0
#         match = HELP_OPTION_REGEX.match(result.output.replace("\n", ""))
#         assert match.group(1) == command_name
# 
#     version_option_switch("-h")
#     version_option_switch("--help")
# 
# def common_version_option(command_entry, command_name):
#     """ Test version message for both standard option switches."""
#     def version_option_switch(option_switch):
#         runner = CliRunner()
#         result = runner.invoke(command_entry, [option_switch])
#         assert result.exit_code == 0
#         match = VERSION_OPTION_REGEX.match(result.output.replace("\n", ""))
#         assert match.group(1) == command_name
#         assert match.group(2) == __version__
# 
#     version_option_switch("-V")
#     version_option_switch("--version")


# Path: tests/test_hyphenate.py
from click.testing import CliRunner
from scripnix.pybin.hyphenate import COMMAND_NAME, hyphenate, main
from .command import common_help_option, common_version_option
import pytest

    assert lines_copy == lines


@pytest.mark.parametrize('arguments,expected', [
    ([], ""),
    (["foo"], "foo\n"),
    (["foo bar", "   bar    baz   ", "baz___bat", "  _quux_  "], "foo-bar\nbar-baz\nbaz___bat\n_quux_\n"),
])
def test_main_arguments(arguments, expected):
    runner = CliRunner()
    arguments_copy = arguments[:]
    result = runner.invoke(main, arguments)
    assert arguments_copy == arguments
    assert result.exit_code == 0
    assert result.output == expected


@pytest.mark.parametrize('stdin,expected', [
    ("", ""),
    ("foo", "foo\n"),
    ("foo bar\n   bar    baz   \nbaz___bat\n  _quux_  ", "foo-bar\nbar-baz\nbaz___bat\n_quux_\n"),
])
def test_main_stdin(stdin, expected):
    runner = CliRunner()
    result = runner.invoke(main, input=stdin)
    assert result.exit_code == 0
    assert result.output == expected


def test_version_option():

    common_version_option(command_entry=main, command_name=COMMAND_NAME)