Coverage for .tox/coverage/lib/python3.11/site-packages/wuttjamaican/cmd/make_appdir.py: 100%
17 statements
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-22 11:28 -0600
« prev ^ index » next coverage.py v7.3.2, created at 2023-11-22 11:28 -0600
1# -*- coding: utf-8; -*-
2################################################################################
3#
4# WuttJamaican -- Base package for Wutta Framework
5# Copyright © 2023 Lance Edgar
6#
7# This file is part of Wutta Framework.
8#
9# Wutta Framework is free software: you can redistribute it and/or modify it
10# under the terms of the GNU General Public License as published by the Free
11# Software Foundation, either version 3 of the License, or (at your option) any
12# later version.
13#
14# Wutta Framework is distributed in the hope that it will be useful, but
15# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17# more details.
18#
19# You should have received a copy of the GNU General Public License along with
20# Wutta Framework. If not, see <http://www.gnu.org/licenses/>.
21#
22################################################################################
23"""
24WuttJamaican - subcommand ``make-appdir``
25"""
27import os
28import sys
30from .base import Subcommand
33class MakeAppDir(Subcommand):
34 """
35 Make or refresh the "app dir" for virtual environment
36 """
37 name = 'make-appdir'
38 description = __doc__.strip()
40 def add_args(self):
41 """ """
42 self.parser.add_argument('--path', metavar='APPDIR',
43 help="Optional path to desired app dir. If not specified "
44 "it will be named ``app`` and placed in the root of the "
45 "virtual environment.")
47 def run(self, args):
48 """
49 This may be used during setup to establish the :term:`app dir`
50 for a virtual environment. This folder will contain config
51 files, log files etc. used by the app.
52 """
53 if args.path:
54 appdir = os.path.abspath(args.path)
55 else:
56 appdir = os.path.join(sys.prefix, 'app')
58 self.make_appdir(appdir, args)
59 self.stdout.write(f"established appdir: {appdir}\n")
61 def make_appdir(self, appdir, args):
62 """
63 Make the :term:`app dir` for the given path.
65 Calls :meth:`~wuttjamaican.app.AppHandler.make_appdir()` to do
66 the heavy lifting.
67 """
68 self.app.make_appdir(appdir)