def cli(input_file, output_file, caption, delimiter, quotechar, display_length, overwrite, serve): """ CSVtoTable commandline utility. """ # Convert CSV file content = convert.convert(input_file, caption=caption, delimiter=delimiter, quotechar=quotechar, display_length=display_length) # Serve the temporary file in browser. if serve: convert.serve(content) # Write to output file elif output_file: # Check if file can be overwrite if not overwrite and not prompt_overwrite(output_file): raise click.Abort() convert.save(output_file, content) click.secho("File converted successfully: {}".format(output_file), fg="green") else: # If its not server and output file is missing then raise error raise click.BadOptionUsage("Missing argument \"output_file\".")
def cli(*args, **kwargs): """ CSVtoTable commandline utility. """ # Convert CSV file content = convert.convert(kwargs["input_file"], **kwargs) # Serve the temporary file in browser. if kwargs["serve"]: convert.serve(content) # Write to output file elif kwargs["output_file"]: # Check if file can be overwrite if (not kwargs["overwrite"] and not prompt_overwrite(kwargs["output_file"])): raise click.Abort() convert.save(kwargs["output_file"], content) click.secho("File converted successfully: {}".format(kwargs["output_file"]), fg="green") else: # If its not server and output file is missing then raise error raise click.BadOptionUsage("Missing argument \"output_file\".")