apipie commands refactoring