extern crate pythonic;
use pythonic::{Argument, Block, Function, FunctionCall, Statement};
fn main() {
let mut program = Block::new();
let mut function = Function::new("hello",
vec![Argument::new("name",
Some("\"World\""),
Some("str"),
Some("The name to say Hello to"))],
&program);
let arguments = vec![Statement::Argument(Argument::bare("Hello")),
Statement::Argument(Argument::input("name"))];
let function_call = FunctionCall::new("print", arguments);
function.add_statement(Statement::FunctionCall(function_call));
function.add_docstring("hello is a function that prints \"Hello\" with the given \
name argument.");
program.add_function(function);
let function_call = FunctionCall::new(
"hello",
vec![
Statement::Argument(Argument::bare("Chris"))
]);
program.add_statement(Statement::FunctionCall(function_call));
let expected = r#"def hello(name="World"):
"""
hello is a function that prints "Hello" with the given name argument.
:param name: str The name to say Hello to
"""
print("Hello", name)
hello("Chris")
"#;
let actual = format!("{}",program);
assert_eq!(expected, actual);
println!("{}", actual);
}