# Path: blimpy/stix.py
# def cmd_tool(args=None):
#     r"""Coomand line parser"""
#     parser = ArgumentParser(description="Make waterfall plots from a single file.")
#     parser.add_argument("input_file", type=str, default=None, help="Input file to plot")
#     parser.add_argument("chunk_count", type=int, default=0, help="Count of same-sized frequency chunks")
#     parser.add_argument("--plot_dir", "-p", type=str, default=".", help="Directory to receive the plot (.png).  Default: current directory.")
#     parser.add_argument("--source_name", "-n", type=str, default=None, help="Source name to override the header field.  Default: None.")
#     parser.add_argument("--stitch", "-s", type=str, default="n", choices=["n", "v", "h"],
#                         help="Stitch files: n(no stitching), v(vertical), or h(horizontal).  Default: n.")
#     parser.add_argument("--dpi", "-d", type=int, default=200,
#                         help="Single image file dots per inch.  Default: 200.")
#     parser.add_argument("--width", "-w", type=float, default=10,
#                         help="Single image file image width in inches.  Default: 10.0.")
#     parser.add_argument("--height", "-t", type=float, default=8,
#                         help="Single image file image height in inches.  Default: 8.0.")
# 
#     if args is None:
#         args = parser.parse_args()
#     else:
#         args = parser.parse_args(args)
#     if args.input_file is None or args.chunk_count < 1:
#         os.system("stix -h")
#         sys.exit(0)
#     if args.dpi < 50:
#         logger.error("stix: --dpi must be at least 50 but I saw: {}!".format(args.dpi))
#         os.system("stix -h")
#         sys.exit(86)
#     if args.width < 6:
#         logger.error("stix: --width must be at least 6 but I saw: {}!".format(args.width))
#         os.system("stix -h")
#         sys.exit(86)
#     if args.height < 5:
#         logger.error("stix: --height must be at least 5 but I saw: {}!".format(args.height))
#         os.system("stix -h")
#         sys.exit(86)
# 
#     # Make the plots.
#     logger.info("Begin")
#     args.plot_dir += "/"
#     args.input_file = os.path.abspath(args.input_file)
#     png_collection, source_name = make_waterfall_plots(args.input_file,
#                                                        args.chunk_count,
#                                                        args.plot_dir,
#                                                        args.width,
#                                                        args.height,
#                                                        args.dpi,
#                                                        source_name=args.source_name)
#     if args.stitch != "n":
#         path_saved_png = args.plot_dir + source_name + ".png"
#         image_stitch(args.stitch, args.chunk_count, png_collection, path_saved_png)
#         for file in png_collection:
#             os.remove(file)
# 
#     logger.info("End")
# 
# Path: tests/data.py



from os.path import dirname
from blimpy.stix import cmd_tool
from tests.data import voyager_fil
import pytest

    args = [voyager_fil, "16", "--plot_dir",  PLOT_DIR]
    execute_command(args)

    args = [voyager_fil, "4", "--plot_dir",  PLOT_DIR, "-s", "v"]
    execute_command(args)

    args = [voyager_fil, "4", "-p",  PLOT_DIR, "--stitch", "h"]
    execute_command(args)

    args = [voyager_fil, "4", "--plot_dir",  PLOT_DIR, "--stitch", "n",
            "--dpi", "100", "--width", "8", "--height", "6"]
    execute_command(args)

    args = [voyager_fil, "4", "-p",  PLOT_DIR, "-s", "n", "-d", "100", "-w", "8", "-t", "6"]
    execute_command(args)

    with pytest.raises(SystemExit):
        args = []
        execute_command(args)

    with pytest.raises(SystemExit):
        args = [voyager_fil, "0", "-p",  PLOT_DIR, "-s", "n", "-d", "50", "-w", "8", "-t", "6"]
        execute_command(args)

    with pytest.raises(SystemExit):
        args = [voyager_fil, "4", "-p",  PLOT_DIR, "-s", "n", "-d", "42", "-w", "8", "-t", "6"]
        execute_command(args)

    with pytest.raises(SystemExit):

# Path: blimpy/stix.py
# def cmd_tool(args=None):
#     r"""Coomand line parser"""
#     parser = ArgumentParser(description="Make waterfall plots from a single file.")
#     parser.add_argument("input_file", type=str, default=None, help="Input file to plot")
#     parser.add_argument("chunk_count", type=int, default=0, help="Count of same-sized frequency chunks")
#     parser.add_argument("--plot_dir", "-p", type=str, default=".", help="Directory to receive the plot (.png).  Default: current directory.")
#     parser.add_argument("--source_name", "-n", type=str, default=None, help="Source name to override the header field.  Default: None.")
#     parser.add_argument("--stitch", "-s", type=str, default="n", choices=["n", "v", "h"],
#                         help="Stitch files: n(no stitching), v(vertical), or h(horizontal).  Default: n.")
#     parser.add_argument("--dpi", "-d", type=int, default=200,
#                         help="Single image file dots per inch.  Default: 200.")
#     parser.add_argument("--width", "-w", type=float, default=10,
#                         help="Single image file image width in inches.  Default: 10.0.")
#     parser.add_argument("--height", "-t", type=float, default=8,
#                         help="Single image file image height in inches.  Default: 8.0.")
# 
#     if args is None:
#         args = parser.parse_args()
#     else:
#         args = parser.parse_args(args)
#     if args.input_file is None or args.chunk_count < 1:
#         os.system("stix -h")
#         sys.exit(0)
#     if args.dpi < 50:
#         logger.error("stix: --dpi must be at least 50 but I saw: {}!".format(args.dpi))
#         os.system("stix -h")
#         sys.exit(86)
#     if args.width < 6:
#         logger.error("stix: --width must be at least 6 but I saw: {}!".format(args.width))
#         os.system("stix -h")
#         sys.exit(86)
#     if args.height < 5:
#         logger.error("stix: --height must be at least 5 but I saw: {}!".format(args.height))
#         os.system("stix -h")
#         sys.exit(86)
# 
#     # Make the plots.
#     logger.info("Begin")
#     args.plot_dir += "/"
#     args.input_file = os.path.abspath(args.input_file)
#     png_collection, source_name = make_waterfall_plots(args.input_file,
#                                                        args.chunk_count,
#                                                        args.plot_dir,
#                                                        args.width,
#                                                        args.height,
#                                                        args.dpi,
#                                                        source_name=args.source_name)
#     if args.stitch != "n":
#         path_saved_png = args.plot_dir + source_name + ".png"
#         image_stitch(args.stitch, args.chunk_count, png_collection, path_saved_png)
#         for file in png_collection:
#             os.remove(file)
# 
#     logger.info("End")
# 
# Path: tests/data.py



# Path: tests/test_stix.py
from os.path import dirname
from blimpy.stix import cmd_tool
from tests.data import voyager_fil
import pytest


    args = [voyager_fil, "16", "--plot_dir",  PLOT_DIR]
    execute_command(args)

    args = [voyager_fil, "4", "--plot_dir",  PLOT_DIR, "-s", "v"]
    execute_command(args)

    args = [voyager_fil, "4", "-p",  PLOT_DIR, "--stitch", "h"]
    execute_command(args)

    args = [voyager_fil, "4", "--plot_dir",  PLOT_DIR, "--stitch", "n",
            "--dpi", "100", "--width", "8", "--height", "6"]
    execute_command(args)

    args = [voyager_fil, "4", "-p",  PLOT_DIR, "-s", "n", "-d", "100", "-w", "8", "-t", "6"]
    execute_command(args)

    with pytest.raises(SystemExit):
        args = []
        execute_command(args)

    with pytest.raises(SystemExit):
        args = [voyager_fil, "0", "-p",  PLOT_DIR, "-s", "n", "-d", "50", "-w", "8", "-t", "6"]
        execute_command(args)

    with pytest.raises(SystemExit):
        args = [voyager_fil, "4", "-p",  PLOT_DIR, "-s", "n", "-d", "42", "-w", "8", "-t", "6"]
        execute_command(args)

    with pytest.raises(SystemExit):

        args = [voyager_fil, "4", "-p",  PLOT_DIR, "-s", "n", "-d", "50", "-w", "5.9", "-t", "6"]