Skip to content

docs: document application command-chain#5599

Open
zyga wants to merge 1 commit intocanonical:mainfrom
zyga:feature/command-chain-docs
Open

docs: document application command-chain#5599
zyga wants to merge 1 commit intocanonical:mainfrom
zyga:feature/command-chain-docs

Conversation

@zyga
Copy link
Contributor

@zyga zyga commented Jul 3, 2025

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run make lint?
  • Have you successfully run make test?

^ No, because those do not seem to work on my Fedora 42 system.

@zyga zyga force-pushed the feature/command-chain-docs branch 4 times, most recently from 2e96ff5 to 5ef96ea Compare July 3, 2025 19:11
@zyga zyga marked this pull request as ready for review July 4, 2025 06:37
@agherzan
Copy link

agherzan commented Jul 4, 2025

This looks good to me. The protocol explanation is a gem.

@mr-cal
Copy link
Collaborator

mr-cal commented Jul 7, 2025

We will need to land #5603 first to fix the docs.

Comment on lines +15 to +16
steps or anything else that makes sense in a given situation. Command chain
elements are usually reusable across applications. Command chain elements are
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command chain elements are usually reusable across applications.

As in different app entries in the same snap or different snaps? The "usually" in this sentence and the next sentence are throwing me off. Is this referring to scripts that get re-used like desktop-launch or alsa-launch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to convey that you can use the same command chain element across many snaps and many apps as they are kind of "middleware". Let me know how to re-phrase that in the text.

@zyga zyga force-pushed the feature/command-chain-docs branch from 758e827 to 30d78fe Compare July 21, 2025 10:33
Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
@zyga zyga force-pushed the feature/command-chain-docs branch from 30d78fe to 6af3172 Compare July 21, 2025 10:35
@zyga zyga requested review from mr-cal and simondeziel July 21, 2025 10:35
Comment on lines +6 to +9
Command chain is a mechanism for running small pieces of code before the main
application executable. The chain uses ``exec`` to transition the process from
the current element of the chain to the next. The last element of the chain is
always the application executable.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Command chain is a mechanism for running small pieces of code before the main
application executable. The chain uses ``exec`` to transition the process from
the current element of the chain to the next. The last element of the chain is
always the application executable.
A command chain is a mechanism for running small pieces of code before the main
application executable. The chain uses ``exec`` to transition the process from
the current element of the chain to the next. The last element of the chain is
always the application executable.

It's important to use articles to distinguish between a concept/category, and actual objects in the software that users interact with.

Comment on lines +7 to +8
application executable. The chain uses ``exec`` to transition the process from
the current element of the chain to the next. The last element of the chain is
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think of:

Suggested change
application executable. The chain uses ``exec`` to transition the process from
the current element of the chain to the next. The last element of the chain is
application executable. The chain uses the ``exec`` command to shift from
the current command to the next. The last element of the chain is

Comment on lines +14 to +18
Command chain may be used to modify process environment, perform initialization
steps or anything else that makes sense in a given situation. Command chain
elements are usually reusable across applications. Command chain elements are
also usually stackable, so an application can use several tailored command
chain elements to perform unrelated functions.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to clear it up a little:

Suggested change
Command chain may be used to modify process environment, perform initialization
steps or anything else that makes sense in a given situation. Command chain
elements are usually reusable across applications. Command chain elements are
also usually stackable, so an application can use several tailored command
chain elements to perform unrelated functions.
A command chains is used to modify the process environment, perform initialization
steps, or any other situation where an ordered sequence of commands is needed.
Chained commands are usually reusable between apps in a part. The commands are
also usually stackable, so an application can use several tailored commands to
perform unrelated functions.

I said "apps in a part", but that might be too narrow for what @zyga is saying.

I'm not sure what we mean by "usually stackable". When are they not stackable? Isn't that an inherent quality of the concept?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The are stackable in the sense that you can take a command chain that, say, handles fontconfig cache, then another one that prepares your XDG configuration, then another one to generate locale data based on what the user is doing and each of those programs is entirely unrelated to each other, and can be used across apps and snaps.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think I follow the metaphor. Is it different than being modular?

Comment on lines +27 to +28
- bin/foo
- bin/bar
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- bin/foo
- bin/bar
- bin/foo
- bin/bar

Not every system in our tooling plays nice with same-indentation collections.

-------

Both ``bin/foo`` and ``bin/bar`` can be written as simple shell scripts or
comprehensive, compiled programs. A shell version might look like this. Notice
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
comprehensive, compiled programs. A shell version might look like this. Notice
compiled programs. A shell version might look like this. Notice

-------

Both ``bin/foo`` and ``bin/bar`` can be written as simple shell scripts or
comprehensive, compiled programs. A shell version might look like this. Notice
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I would put the "Notice..." sentence after the code block, so the reader has the chance to look at the code and think about it before we isolate part of it.

Comment on lines +42 to +49
calling ``exec`` (without forking the process). Here both ``bin/foo`` and
``bin/bar`` would follow the same protocol, ultimately executing ``bin/hello``.
The next element of the chain is passed through the process argument vector.

In the example above, ``snap-exec`` would call ``exec bin/foo bin/bar
bin/hello`` with ``bin/foo`` as the program path and program name and ``bin/bar
bin/hello`` as arguments. This protocol continues until the application entry
point is reached.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Food for thought: this could also be visualised as a series of nodes in ASCII. It would reinforce the meaning.

--------

Every element of the chain is responsible for executing the next chain by
calling ``exec`` (without forking the process). Here both ``bin/foo`` and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
calling ``exec`` (without forking the process). Here both ``bin/foo`` and
calling ``exec`` (without forking the process). Continuing with the previous example, both ``bin/foo`` and

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants