Skip to content

Commit 49ba0d3

Browse files
Merge pull request #1903 from nickozilla/disable_elementary_logo_print
Add function for `disable_elementary_logo_print`
2 parents 823ceed + 87f6bdb commit 49ba0d3

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

elementary/cli/cli.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import click
55

6+
import elementary.cli.logo
67
import elementary.cli.upgrade
78
from elementary.config.config import Config
89
from elementary.monitor.cli import monitor, report, send_report
@@ -11,15 +12,7 @@
1112
from elementary.utils import package
1213
from elementary.utils.log import get_logger, set_root_logger_handlers
1314

14-
ELEMENTARY_LOGO = r"""
15-
________ __
16-
/ ____/ /__ ____ ___ ___ ____ / /_____ ________ __
17-
/ __/ / / _ \/ __ `__ \/ _ \/ __ \/ __/ __ `/ ___/ / / /
18-
/ /___/ / __/ / / / / / __/ / / / /_/ /_/ / / / /_/ /
19-
/_____/_/\___/_/ /_/ /_/\___/_/ /_/\__/\__,_/_/ \__, /
20-
/____/
21-
"""
22-
click.echo(f"{ELEMENTARY_LOGO}\n")
15+
elementary.cli.logo.print_elementary_logo()
2316
elementary.cli.upgrade.recommend_version_upgrade()
2417

2518
logger = get_logger(__name__)

elementary/cli/logo.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import click
2+
3+
from elementary.config.config import Config
4+
5+
ELEMENTARY_LOGO = r"""
6+
________ __
7+
/ ____/ /__ ____ ___ ___ ____ / /_____ ________ __
8+
/ __/ / / _ \/ __ `__ \/ _ \/ __ \/ __/ __ `/ ___/ / / /
9+
/ /___/ / __/ / / / / / __/ / / / /_/ /_/ / / / /_/ /
10+
/_____/_/\___/_/ /_/ /_/\___/_/ /_/\__/\__,_/_/ \__, /
11+
/____/
12+
"""
13+
14+
15+
def print_elementary_logo():
16+
config = Config()
17+
18+
if config.disable_elementary_logo_print:
19+
return
20+
else:
21+
click.echo(f"{ELEMENTARY_LOGO}\n")

elementary/config/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,10 @@ def __init__(
206206
"disable_elementary_version_check", False
207207
)
208208

209+
self.disable_elementary_logo_print = config.get(
210+
"disable_elementary_logo_print", False
211+
)
212+
209213
def _load_configuration(self) -> dict:
210214
if not os.path.exists(self.config_dir):
211215
os.makedirs(self.config_dir)

tests/unit/config/test_config.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"workflows": False,
1717
},
1818
"disable_elementary_version_check": True,
19+
"disable_elementary_logo_print": True,
1920
}
2021

2122
WORKFLOWS_CONFIG = {
@@ -63,6 +64,13 @@ def test_disable_elementary_version_check(config: Config):
6364
)
6465

6566

67+
@pytest.mark.parametrize("config", [CONFIG], indirect=["config"])
68+
def test_disable_elementary_logo_print(config: Config):
69+
assert (
70+
config.disable_elementary_logo_print == CONFIG["disable_elementary_logo_print"]
71+
)
72+
73+
6674
@pytest.mark.parametrize("config", [WORKFLOWS_CONFIG], indirect=["config"])
6775
def test_slack_workflows_config_get_workflows(config: Config):
6876
assert config.is_slack_workflow == WORKFLOWS_CONFIG["slack"]["workflows"]

0 commit comments

Comments
 (0)