Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Kdb cli rewrite #4922

Closed
wants to merge 23 commits into from
Closed

Kdb cli rewrite #4922

wants to merge 23 commits into from

Conversation

hannes99
Copy link
Contributor

Added tests and if a command does not exist yet in C, the C++ implementation will be used. And due to #4444 the new implementation does not rely on specload anymore, support for it (kdb --elektra-spec) could be added easily if that would still make sense.

Basics

  • Short descriptions of your changes are in the release notes
    (added as entry in doc/news/_preparation_next_release.md which contains _(my name)_)
    Please always add them to the release notes.
  • Details of what you changed are in commit messages
    (first line should have module: short statement syntax)
  • References to issues, e.g. close #X, are in the commit messages.
  • The buildservers are happy. If not, fix in this order:
    • add a line in doc/news/_preparation_next_release.md
    • reformat the code with scripts/dev/reformat-all
    • make all unit tests pass
    • fix all memleaks
    • fix the CI itself (or rebase if already fixed)
  • The PR is rebased with current master.

Checklist

  • I added unit tests for my code
  • I fully described what my PR does in the documentation
    (not in the PR description)
  • I fixed all affected documentation (see Documentation Guidelines)
  • I fixed all affected decisions (see Decision Process)
  • I added code comments, logging, and assertions as appropriate (see Coding Guidelines)
  • I updated all meta data (e.g. README.md of plugins and METADATA.ini)
  • I mentioned every code not directly written by me in reuse syntax

Review

Labels

  • Add the "work in progress" label if you do not want the PR to be reviewed yet.
  • Add the "ready to merge" label if everything is done and no further pushes are planned by you.

src/tools/kdb/get.c Fixed Show fixed Hide fixed
src/tools/kdb/cmerge.c Fixed Show fixed Hide fixed
src/tools/kdb/colors.c Fixed Show fixed Hide fixed
src/tools/kdb/mv.c Fixed Show fixed Hide fixed
src/tools/kdb/cp.c Fixed Show fixed Hide fixed
src/tools/kdb/rm.c Fixed Show fixed Hide fixed
src/tools/kdb/get.c Fixed Show fixed Hide fixed
@hannes99 hannes99 force-pushed the kdb_cli_rewrite branch 12 times, most recently from 35e9cbc to adb7dfe Compare May 12, 2023 13:06
src/tools/kdb/colors.c Fixed Show fixed Hide fixed
@hannes99 hannes99 force-pushed the kdb_cli_rewrite branch 5 times, most recently from 9cf997c to 7458acd Compare May 14, 2023 08:25
src/tools/kdb/colors.c Fixed Show fixed Hide fixed
@hannes99 hannes99 force-pushed the kdb_cli_rewrite branch 5 times, most recently from 32fa246 to d79b382 Compare May 14, 2023 12:34
Copy link
Contributor

@markus2330 markus2330 left a comment

Choose a reason for hiding this comment

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

Unfortunately still no reviews. Do more reviews for others and specifically ask others to do a review.

Anyway, the PR is a big progress. I am okay with replacing individual commands but without the possibility to compile kdb completely without C++, the whole PR only goes the half way. This does not necessarily need to happen within this PR, though.

The main issue is that the release notes do not properly describe what was done. In particular it should point to tutorials/tests that fix bugs etc. What are your contributions? Which advantage to we have if we merge this PR?

@@ -324,6 +324,15 @@ This section keeps you up-to-date with the multi-language support provided by El
- <<TODO>>
- <<TODO>>

### KDB
Copy link
Contributor

Choose a reason for hiding this comment

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

Please make highlight out of it.

@@ -324,6 +324,15 @@ This section keeps you up-to-date with the multi-language support provided by El
- <<TODO>>
- <<TODO>>

### KDB

- Replace C++ of the CLI by a C version, C++ is fallback for not yet implemented commands _(@hannes99)_
Copy link
Contributor

Choose a reason for hiding this comment

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

How is it possible to compile without having C++ (which was the goal)?

Comment on lines +332 to +333
- Disable cascading writes as described in #3742
- Fix inconsistent return values #1563
Copy link
Contributor

Choose a reason for hiding this comment

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

Explain what exactly was done here and give examples (or link to new tests that show correct behavior).

- Add extra tests for CLI commands
- Disable cascading writes as described in #3742
- Fix inconsistent return values #1563
- Update documentation, tutorials and examples where they would not match the new C version
Copy link
Contributor

Choose a reason for hiding this comment

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

Link to the places where relevant/bigger changes were done.

@@ -91,43 +91,6 @@ The **proc** namespace is not accessible by the command line tool **kdb**, as it

The **spec** namespace is used to store metadata about keys and therefore Elektra handles the **spec** namespace differently to other namespaces. The following part of the tutorial is dedicated to the impact of the **spec** namespace on cascading lookups.

## Write Operations and the cascading Namespace

If a value is to be written to a cascading key, i.e., a key starting with '/', only cascading keys that resolve to an existing key will be used.
Copy link
Contributor

Choose a reason for hiding this comment

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

Demonstrate that it fails.

@@ -0,0 +1,254 @@
/**
Copy link
Contributor

Choose a reason for hiding this comment

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

We only want cmerge and it should be called merge, the old merge can be removed. See also #3131

Copy link
Contributor

@tmakar tmakar left a comment

Choose a reason for hiding this comment

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

Very good work here! I added some notes. For some comments it makes sense to check other occurences.


#include <kdb.h>

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

This is very minor, but what kind of function documentation do we follow in general? For some I see that we are doing documentation in the *.c files and some things are documented in *.h.

if (toLookUp == NULL)
{
ELEKTRA_SET_VALIDATION_SEMANTIC_ERRORF (errorKey, "'%s' is not a valid key name", keyName (toLookUp));
keyDel (toLookUp);
Copy link
Contributor

Choose a reason for hiding this comment

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

What about moving all the free memory code to cleanup section and check there if the variable is NULL and if not free the memory?

Key * printTrace (KeySet * ks, Key * key, Key * found, elektraLookupFlags options);
Key * warnOnMeta (KeySet * ks, Key * key, Key * found, elektraLookupFlags options);
void printOptions (elektraLookupFlags options);
void setCallback (Key * key, Key * (*f) (KeySet * ks, Key * key, Key * found, elektraLookupFlags flags));
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest describing what kind of callback should be set here. The signature of *f is not really intuitive. And maybe also add some description for what the callback is needed.


const char * metaName = GET_OPTION (options, "metaname");

Key * toLookUp = keyNew (name, KEY_END);
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest moving toLookUp key initialization right before Key * key = ksLookup (conf, toLookUp, KDB_O_NONE);. IIRC, I have read in our coding conventions CODING.md that we should initialize code as late as possible and it is good practice in general.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe some description in this header file 🤔 ?

@kodebach kodebach mentioned this pull request May 18, 2023
19 tasks
hannes99 added 5 commits May 19, 2023 05:54
... and remove cpp implementation
... and remove cpp implementation
... and remove cpp implementation
... and remove cpp implementation
... and remove cpp implementation
@hannes99 hannes99 force-pushed the kdb_cli_rewrite branch 2 times, most recently from 13cb196 to 3dd3e33 Compare May 19, 2023 05:17
.. remove cpp implementation and fix #3131
@hannes99 hannes99 closed this May 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants