canonical / canonical/craft-cli

Greeting doesn't output as expected

Open
#128 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
16
Forks
27
Avg merge
1d 22h
Merged PRs (30d)
10

Description

Uncovered with https://github.com/snapcore/snapcraft/pull/3958

Snapcraft makes the two calls on startup:
```
emit.init(
mode=get_verbosity(), # verbosity comes from environmental variable
)

...

dispatcher.pre_parse_args(sys.argv[1:])
```
These two calls both call `craft_cli.set_mode()`. If the verbosity levels don't match between these two calls, then craft-cli may not log as expected. See scenarios below.

## Scenario 1

Greeting logged when in `quiet`.

### input
`SNAPCRAFT_VERBOSITY_LEVEL=trace snapcraft --verbosity=quiet`

### output
```
2022-10-26 11:26:15.135 Starting Snapcraft 7.2.1.post5+git529c27a2
2022-10-26 11:26:15.135 Logging execution to '/home/developer/.cache/snapcraft/log/snapcraft-20221026-112615.134692.log'
```
## Scenario 2

Greeting logged twice.

## input
`SNAPCRAFT_VERBOSITY_LEVEL=trace snapcraft --verbosity=trace`

### output
```
2022-10-26 11:25:57.052 Starting Snapcraft 7.2.1.post5+git529c27a2
2022-10-26 11:25:57.052 Logging execution to '/home/developer/.cache/snapcraft/log/snapcraft-20221026-112557.051720.log'
2022-10-26 11:25:57.052 Starting Snapcraft 7.2.1.post5+git529c27a2
2022-10-26 11:25:57.052 Logging execution to '/home/developer/.cache/snapcraft/log/snapcraft-20221026-112557.051720.log'
... (logs continue in trace-level)
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the two scenarios with SNAPCRAFT_VERBOSITY_LEVEL and the matching snapcraft --verbosity values. Trace emit.init(), dispatcher.pre_parse_args(sys.argv[1:]), and their calls to craft_cli.set_mode(). Done means quiet mode produces no greeting and trace mode produces the greeting once, without duplicate output.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.