Skip to main content

Easy coding

Project description

ezcoding

简介

利用模板,快速生成文本文件,帮助开发者快速写代码。

配置

先安装 Python,再安装 ezcoding

pip install ezcoding

新建 templates 文件夹,用于存放模板文件。模板文件是一个 Python 脚本文件,继承 Template 类,再通过一个 get_template 函数返回其实例。

# -*- coding: utf-8 -*-

from typing import AnyStr, Dict

from ezcoding import Template, Generator
from ezcoding.generators import HeaderMacroGenerator, AuthorGenerator, DateStringGenerator


class Header(Template):

    def __init__(self):
        super().__init__()

    def get_text(self) -> AnyStr:
        return """/*
 * author: $Author$
 * date: $Date$
 */

#ifndef $HeaderMacro$
#define $HeaderMacro$

namespace $Namespace$
{
}

#endif // $HeaderMacro$
"""

    def get_value_generators(self) -> Dict[AnyStr, Generator]:
        return {
            'HeaderMacro': HeaderMacroGenerator(prefix='DEMO'),
            'Author': AuthorGenerator(),
            'Date': DateStringGenerator()
        }


def get_template() -> Template:
    return Header()

在用户目录下,新建 .ezcoding 文件,按以下格式指定模板存放的目录。

{
    "template_dir": "C:\\path\\to\\your\\template\\directory"
}

确保将 ezc.exe 所在目录添加到环境变量 Path 中,使得在任意目录下都可以访问到 ezc 命令。

使用

创建文件

在希望新建文件的目录下,使用创建子命令(create)创建文件。以下命令使用 Header 模板,创建文件 HelloWorld.h

子命令后:

  • 第一个参数为待创建的文件名。
  • 第二个参数为模板名称。
  • 第三个及以后参数为变量及值对,可以有多个,形式为 variable=value
ezc create HelloWorld.h Header Namespace=demo

查看模板

使用 list 子命令查看模板的目录及模板的名称。

ezc list

查看帮助

使用 help 子命令查看帮助。

ezc help

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ezcoding-0.2.3.tar.gz (11.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ezcoding-0.2.3-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file ezcoding-0.2.3.tar.gz.

File metadata

  • Download URL: ezcoding-0.2.3.tar.gz
  • Upload date:
  • Size: 11.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for ezcoding-0.2.3.tar.gz
Algorithm Hash digest
SHA256 30d7ef49afa298bfa5145786be2193a3cb8c3dec4def90eae27ac37f2cbe4ad9
MD5 15d148661878fa9a17122c845bd6ac25
BLAKE2b-256 af5506a7713a0d02b1121fbab66bd4ceef2acdd8fac461b59f6919a35502fe9d

See more details on using hashes here.

File details

Details for the file ezcoding-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: ezcoding-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 16.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.3

File hashes

Hashes for ezcoding-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 0c246b6483bf619c74af754bbab3763b195537b74516c4e27e07cd58c2fca97a
MD5 e38b5ef52640e3b58400a8fdad8e9253
BLAKE2b-256 375e7b2e2678fef2e895e37d0bd915e871ab374f82c9eb65d50a65314f473db6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page