Skip to content

Commit e3cdde8

Browse files
committed
CLI: only create local configuration file
1 parent daa14d9 commit e3cdde8

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

stagpy/commands.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
from shutil import get_terminal_size
1010
from textwrap import TextWrapper, indent
1111

12-
import loam.tools
1312
import pandas
1413

1514
from . import __version__, conf, phyvars, stagyydata
1615
from ._helpers import baredoc
17-
from .config import CONFIG_FILE
16+
from .config import CONFIG_LOCAL
1817

1918
if typing.TYPE_CHECKING:
2019
from typing import Callable, Iterable, Mapping, Optional, Sequence, Tuple, Union
@@ -200,11 +199,7 @@ def config_cmd() -> None:
200199
Other Parameters:
201200
conf.config
202201
"""
203-
if not (
204-
conf.common.config
205-
or conf.config.create
206-
or conf.config.update
207-
or conf.config.edit
208-
):
202+
if conf.config.create:
203+
conf.default_().to_file_(CONFIG_LOCAL)
204+
else:
209205
config_pp(sec.name for sec in fields(conf))
210-
loam.tools.config_cmd_handler(conf, conf.config, CONFIG_FILE)

stagpy/config.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from typing import Dict, Optional, Sequence, Union
1212

1313
import loam.parsers as lprs
14-
from loam import tools
1514
from loam.base import ConfigBase, Section, entry
1615
from loam.collections import MaybeEntry, TupleEntry
1716
from loam.tools import command_flag, path_entry, switch_opt
@@ -228,6 +227,13 @@ class Var(Section):
228227
refstate: bool = command_flag("print refstate variables")
229228

230229

230+
@dataclass
231+
class ConfSection(Section):
232+
"""Config command."""
233+
234+
create: bool = command_flag("create config file")
235+
236+
231237
@dataclass
232238
class Config(ConfigBase):
233239
"""StagPy configuration."""
@@ -243,4 +249,4 @@ class Config(ConfigBase):
243249
plates: Plates
244250
info: Info
245251
var: Var
246-
config: tools.ConfigSection
252+
config: ConfSection

0 commit comments

Comments
 (0)