Commit Graph
9 Commits
Author SHA1 Message Date
Mike Yuan 0e3638380d various: unexport a few internal structs
We don't expose destructors for these internal structs already.
Let's make the struct itself implementation detail too.
2024-01-03 08:40:33 +09:00
Zbigniew Jędrzejewski-Szmek 329050c5e2 systemctl: add "edit --stdin"
This is a fancy wrapper around "cat <<EOF", but:
- the user doesn't need to figure out the file name,
- parent directories are created automatically,
- daemon-reload is implied,
so it's a convenient way to create units or drop-ins.

Closes https://github.com/systemd/systemd/issues/21862.
2023-12-05 18:47:19 +01:00
Mike Yuan bc6c7a58c2 edit-util: introduce overwrite_with_origin switch
Before this commit, if `original_path` is given,
it will always be used to overwrite `path`.
After this commit, it's controlled by the newly-added
switch `overwrite_with_origin`.
2023-04-07 16:13:00 +08:00
Mike Yuan 6e5d0e319e edit-util: add DROPIN_MARKER_{START,END} 2023-04-07 16:10:54 +08:00
Mike Yuan 78e3200354 edit-util: include the correct header 2023-03-13 01:44:51 +08:00
Yu Watanabe 043db3400c edit-util: make EditFile take reference of EditFileContext
No functional change, just preparation for later commits.
2023-03-11 22:19:22 +09:00
Mike Yuan 9a11b4f953 edit-util: introduce EditFileContext
This is a rather large change which moves
the add and install logic into edit-util.

We store an EditFile array and the number of
elements, along with the edit markers used in
temporary files and whether to remove the parent
directories of the target files if they're empty
in an EditFileContext object.

Call edit_files_add() to add an file to edit,
and do_edit_files_and_install() to do the actual
editing (through create_edit_temp_file(),
run_editor() and trim_edit_markers()).
After that, edit_file_context_done() can be used
to destroy the object.
2023-03-11 02:01:00 +08:00
Mike Yuan fa2413dd57 edit-util: several cleanups to create_edit_temp_file
original_path and comment_paths can now be used
together.

Removes reference to "unit"
2023-03-11 01:38:52 +08:00
Mike Yuan a01c4bc9af shared: extract edit-util from systemctl-edit 2023-03-11 01:38:52 +08:00