Skip to content

Commit

Permalink
Add a configuration file (#30)
Browse files Browse the repository at this point in the history
Store default settings in a local configuration file (user home folder)
  • Loading branch information
seapagan authored Jul 30, 2023
1 parent df8542e commit e619ee6
Show file tree
Hide file tree
Showing 18 changed files with 420 additions and 152 deletions.
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# TODO List

- Add testing with [Pytest](https://pytest.org)
- Add a documentation website using [MkDocs](https://mkdocs.org)
- Add option to generate a skeleton MkDocs website for the new project
- Implement saving settings to a file (Name, Email, Default License, etc.) Have
a new command to create and edit the settings
- Ask for more settings ie homepage, repo, etc. and add them to the generated
`pyproject.toml` file (if the new project is likely to be uploaded to PyPI)
- check manually entered package name to ensure no dashes.
Expand All @@ -16,3 +13,6 @@
is already taken. If it is, either abort or ask the user if they want to
continue (making clear they will need to rename the package before it can be
uploaded).
- option to dump the default template files to a local directory so they can be
edited and used as custom templates, optionally dumping to the
`~/.pymaker/templates` folder overwriting existing customizations.
42 changes: 42 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Configuration

## Configuration file

This app needs minimal configuration, currently just storing defaults for the
`author_name`, `author_email` and `default_license`. This is stored in a
configuration file in a sub-folder of the user's home directory. By default (and
currently the only option) this file is stored in `~/.pymaker/config.toml`. An
example of this file is:

```toml
[pymaker]
author_email = "[email protected]"
author_name = "Python User"
default_license = "MIT"
schema_version = "1.0" # for internal use, generally don't change this
```

If this file does not exist, it will be created on first run. The app will ask
for the values of these fields. For `author_name` and `author_email` it will try
to use the current git user name and email if they are set as defaults, though
the user can override these.

## View configuration

You can list the current configuration with the command:

```
$ pymaker config show
```

## Set configuration

The configuration is set the first time you run the app, but you can change
these defaults at any time using the command:

```console
$ pymaker config change
```

The latter command will prompt you for the values of the fields, and then update
the configuration file.
8 changes: 7 additions & 1 deletion docs/quick-start.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Quick Start

## Create a new project

To create a new project, run the following command:

```console
Expand All @@ -25,6 +27,8 @@ The App will then run the steps needed to get you started quickly:

You will be asked a series of questions to customise the new project.

## Choose a package name and description

When it asks "Package Name?" you can choose two variants :

1. **If you are creating a standard Python package** that can optionally be
Expand All @@ -36,6 +40,8 @@ When it asks "Package Name?" you can choose two variants :
be placed in the project root and no package folder will be created or
referenced.

## Start developing

You should now change into the new directory, install dependencies and activate
the virtual environment:

Expand All @@ -47,7 +53,7 @@ $ poetry shell

Now, you can start developing :smile:

Example run :
## Example run

```console
$ pymaker new test-project
Expand Down
6 changes: 3 additions & 3 deletions docs/tasks.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Task Runner

The task-runner [Poe the
Poet](https://github.com/nat-n/poethepoet){:target="_blank"} is installed as a
development dependency which allows us to run simple tasks (similar to npm
`scripts`).
Poet](https://github.com/nat-n/poethepoet){:target="_blank"} is installed in the
new project as a development dependency which allows us to run simple tasks
(similar to npm `scripts`).

These are run (from within the virtual environment) using the `poe` command and
then the script name, for example:
Expand Down
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ nav:
- Home: index.md
- Installation: installation.md
- Quick Start: quick-start.md
- Configuration: configuration.md
- Task Runner: tasks.md
- License: license.md
Loading

0 comments on commit e619ee6

Please sign in to comment.