Skip to content

fix: initial watch list formatting#268

Merged
ctrox merged 1 commit intomainfrom
watch-fix-header
Sep 9, 2025
Merged

fix: initial watch list formatting#268
ctrox merged 1 commit intomainfrom
watch-fix-header

Conversation

@ctrox
Copy link
Contributor

@ctrox ctrox commented Aug 15, 2025

We need to do an initial list call before the watch to get a properly formatted list. This was in the watch branch for quite a while but I removed it later as I though it was not needed.

If we don't do the initial list, the output can look like this:

PROJECT                NAME                    BUILDNAME      APPLICATION
nine-staging-cyrill    eternal-azazel-qwhlr    go-build-12    go
nine-staging-cyrill    full-komodo-d6w95       go-build-13    go
nine-staging-cyrill    known-quicksilver-6hb9b    go-build-14    go
nine-staging-cyrill    loved-warbound-4kgmq       go-build-11    go

This is fixed with this commit:

PROJECT                NAME                       BUILDNAME      APPLICATION
nine-staging-cyrill    loved-warbound-4kgmq       go-build-11    go
nine-staging-cyrill    eternal-azazel-qwhlr       go-build-12    go
nine-staging-cyrill    full-komodo-d6w95          go-build-13    go
nine-staging-cyrill    known-quicksilver-6hb9b    go-build-14    go

This is because the third element is wider but the tabwriter is spaced out based on the first item if we do a watch without an initial list. Of course if our watch would later result in a new but wider item, the table would be misaligned again but that is unavoidable. As a secondary benefit, the initial list will be correctly sorted.

We need to do an initial list call before the watch to get a properly
formatted list. This was in the watch branch for quite a while but I
removed it later as I though it was not needed.

If we don't do the initial list, the output can look like this:

```
PROJECT                NAME                    BUILDNAME      APPLICATION
nine-staging-cyrill    eternal-azazel-qwhlr    go-build-12    go
nine-staging-cyrill    full-komodo-d6w95       go-build-13    go
nine-staging-cyrill    known-quicksilver-6hb9b    go-build-14    go
nine-staging-cyrill    loved-warbound-4kgmq       go-build-11    go
```

This is fixed with this commit:

```
PROJECT                NAME                       BUILDNAME      APPLICATION
nine-staging-cyrill    loved-warbound-4kgmq       go-build-11    go
nine-staging-cyrill    eternal-azazel-qwhlr       go-build-12    go
nine-staging-cyrill    full-komodo-d6w95          go-build-13    go
nine-staging-cyrill    known-quicksilver-6hb9b    go-build-14    go
```

This is because the third element is wider but the tabwriter is spaced
out based on the first item if we do a watch without an initial list. Of
course if our watch would later result in a new but wider item, the
table would be misaligned again but that is unavoidable. As a secondary
benefit, the initial list will be correctly sorted.
@ctrox ctrox merged commit cdd73ec into main Sep 9, 2025
3 checks passed
@ctrox ctrox deleted the watch-fix-header branch September 9, 2025 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants