Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multy cli support #16

Merged
merged 20 commits into from
Oct 22, 2024
Merged

Multy cli support #16

merged 20 commits into from
Oct 22, 2024

Conversation

outscale-mgo
Copy link
Contributor

No description provided.

@outscale-mgo outscale-mgo force-pushed the multy-cli-support branch 3 times, most recently from 570adc3 to f8da4b5 Compare October 8, 2024 12:38
Signed-off-by: Matthias Gatto <[email protected]>
Signed-off-by: Matthias Gatto <[email protected]>
Signed-off-by: Matthias Gatto <[email protected]>
Copy link

@outscale-rce outscale-rce left a comment

Choose a reason for hiding this comment

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

Clarifies some key points and correct grammar.

README.md Outdated
@@ -3,13 +3,76 @@

## Usage

configure COGNAC using `./configure`, then use either `cognac_gen.sh SOURCE DEST LANGUAGE` directly, or the Makefile.

*note: The main purpose of this repository is to generate source code. If your goal is to compile osc-sdk-c or oapi-cli, please use their respective repositories, which handle the code generation process for you.*

Choose a reason for hiding this comment

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

The primary purpose of this repository is to generate source code. If your goal is to compile osc-sdk-c or oapi-cli, please refer to their respective repositories, which handle the code generation process for you.

README.md Outdated
*note: The main purpose of this repository is to generate source code. If your goal is to compile osc-sdk-c or oapi-cli, please use their respective repositories, which handle the code generation process for you.*

### Brief

configure COGNAC Makefile using `./configure`

Choose a reason for hiding this comment

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

To configure the COGNAC Makefile, use ./configure.

README.md Outdated
### Brief

configure COGNAC Makefile using `./configure`
you can use `cognac_gen.sh SOURCE DEST LANGUAGE` to generate a file from a template

Choose a reason for hiding this comment

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

You can use cognac_gen.sh SOURCE DEST LANGUAGE to generate files from a template.

README.md Outdated

configure COGNAC Makefile using `./configure`
you can use `cognac_gen.sh SOURCE DEST LANGUAGE` to generate a file from a template
the Makefile is here to help you generate all the files.

Choose a reason for hiding this comment

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

The Makefile is designed to help you generate all the required files.

README.md Outdated
configure COGNAC Makefile using `./configure`
you can use `cognac_gen.sh SOURCE DEST LANGUAGE` to generate a file from a template
the Makefile is here to help you generate all the files.
if you want to generate everything, just call `make`

Choose a reason for hiding this comment

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

If you want to generate everything, simply run make.

README.md Outdated

It use lot of small program interactive together, and is complet by a few utilities in bin/ that do some text handling.

Makefile was create to... make files, and so Makefile is use that way.

Choose a reason for hiding this comment

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

The Makefile was originally created to "make" files, and COGNAC uses it in that way.

README.md Outdated

Makefile was create to... make files, and so Makefile is use that way.

Scripts use by the makefile, do the job of creating the file, and the makefile check that they have been created, and that there's no need to rebuild them.

Choose a reason for hiding this comment

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

The scripts used by the Makefile handle the actual file creation, while the Makefile itself checks if files need to be rebuilt or not.

README.md Outdated
### Templating

the templating system cognac is homemade, it read SRC file and generate DEST file
it uses multiple keyword, each surrounded by 4 underscore (example: `____api_version____`)

Choose a reason for hiding this comment

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

COGNAC’s templating system is homemade. It reads SRC files and generates DEST files. It uses several keywords, each surrounded by four underscores (e.g., ____api_version____).

README.md Outdated

the templating system cognac is homemade, it read SRC file and generate DEST file
it uses multiple keyword, each surrounded by 4 underscore (example: `____api_version____`)
as an example, you can look at [lib.h](./lib.h) or [main_tpl.c](./main_tpl.c)

Choose a reason for hiding this comment

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

For example, you can check out lib.h or main_tpl.c.

README.md Outdated
as an example, you can look at [lib.h](./lib.h) or [main_tpl.c](./main_tpl.c)

Some rules support multiples languages sure as `____func_code____`, which will generate functions calls,
and some are not. (like `____functions_proto____` which for now support only C)

Choose a reason for hiding this comment

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

Some rules support multiple languages, like ____func_code____, which generates function calls. Others, like ____functions_proto____, currently support only C.

/* a is an array of "flexible size", v is the value to push, and pa
* is use to store the pointer somewhere so we can free everything
* esilly
*/

Choose a reason for hiding this comment

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

a is an array with a flexible size, v is the value to push, and pa is used to store the pointer so that we can easily free everything later.

cognac_gen.sh Outdated
cat <<EOF
aditional=$(json-search -n additionalProperties <<< $componant)

if [ "$aditional" == "null" -o "$aditional" == "false" ]; then

Choose a reason for hiding this comment

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

if [ "$aditional" == "null" || "$aditional" == "false" ]; then

cognac_gen.sh Outdated
# no type check are made here, the aditional stuff is assumed to be a string
cat <<EOF
{
struct additional_strings *elem = malloc(sizeof *elem);

Choose a reason for hiding this comment

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

if (!elem) {
   fprintf(stderr, "Memory allocation failed");
   return -1;
}

cognac_gen.sh Outdated
{
fprintf(stderr, "'%s' not an argumemt of '$s'\n", str);
return -1;
}
EOF
else
# no type check are made here, the aditional stuff is assumed to be a string

Choose a reason for hiding this comment

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

no type checks are made here, the additional stuff is assumed to be a string

aditional=$(json-search -n additionalProperties <<< $base)

if [ "$aditional" != "null" -a "$aditional" != "false" ]; then
# no type check are made here, the aditional stuff is assumed to be a string

Choose a reason for hiding this comment

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

no type checks are made here, the additional stuff is assumed to be a string

fi

aditional=$(json-search -n additionalProperties <<< $base)

if [ "$aditional" != "null" -a "$aditional" != "false" ]; then

Choose a reason for hiding this comment

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

if [ "$additional" != "null" ] && [ "$additional" != "false" ]; then

if [ "$aditional" != "null" -a "$aditional" != "false" ]; then
# no type check are made here, the aditional stuff is assumed to be a string
cat <<EOF
struct additional_strings **elems = args->additional_strs;

Choose a reason for hiding this comment

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

if (!elems) {
    fprintf(stderr, "Error: additional_strs is null");
    return -1;
}

mk_args.c.sh Outdated
@@ -75,6 +75,13 @@ write_struct() {

type_to_ctype "$t" "$snake_n"
done
aditional=$(json-search -n additionalProperties <<< $st_info)

if [ "$aditional" != "null" -a "$aditional" != "false" ]; then

Choose a reason for hiding this comment

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

if [ "$additional" != "null" ] && [ "$additional" != "false" ]; then

Copy link
Contributor Author

Choose a reason for hiding this comment

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

why not, but why is it better ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

annyway, I change the code to use bash built-in [[

mk_args.c.sh Outdated
aditional=$(json-search -n additionalProperties <<< $st_info)

if [ "$aditional" != "null" -a "$aditional" != "false" ]; then
# no type check are made here, the aditional stuff is assumed to be a string

Choose a reason for hiding this comment

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

No type checks are made here; the additional stuff is assumed to be a string

@outscale-mgo outscale-mgo merged commit 837ca89 into master Oct 22, 2024
3 checks passed
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.

3 participants