Commit 3b5f4470 authored by Greg Williams's avatar Greg Williams
Browse files

Added more robust command line parsing. Updated README.md to docuement usage of kinetic-c utility

parent 784c14e4
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -67,6 +67,30 @@ Examples

The following examples are provided for development reference and as utilities to aid development

In order to execute a given example, execute `kinetic-c` with a given example name and optional arguments (below)


First, `cd` into the `build/release` folder, and then execute the desired command.
If no command is specified, kinetic-c will execute all of the example commands.


**e.g.** - Execute the NoOp operation against default host: `localhost`:

```
cd build/release
kinetic-c noop
```

**e.g.** - Execute the NoOp operation against `my-kinetic-server.com`:

```
cd build/release
kinetic-c noop --host my-kinetic-server.com
```


`noop [--hostname|-h "some_host.com"|123.253.253.23]`

`read_file_blocking` (incomplete!)

`read_file_nonblocking` (incomplete!)
+54 −18
Original line number Diff line number Diff line
@@ -32,18 +32,53 @@ int main(int argc, char** argv)
    const int64_t clusterVersion = 0;
    const int64_t identity = 1;
    const char* key = "asdfasdf";
    bool doNoOp = false;
    bool argumentError = true;

    // Parse command line arguments, if supplied
    if (argc >= 3)
    if (argc == 1)
    {
        // Simple parser for --host <ip/hostname> for now
        if ((strcmp("--host", argv[1]) == 0) ||
            (strcmp("--host", argv[1]) == 0))
        doNoOp = true;
        argumentError = false;
    }
    else if (argc == 2)
    {
        if (strcmp("noop", argv[1]) == 0)
        {
            doNoOp = true;
            argumentError = false;
        }
    }
    else if (argc == 3)
    {
        if ((strcmp("--host", argv[1]) == 0) || (strcmp("-h", argv[1]) == 0))
        {
            strcpy(host, argv[2]);
            doNoOp = true;
            argumentError = false;
        }
    }
    else if (argc > 3)
    {
        // Simple parser for --host <ip/hostname> for now
        if ((strcmp("noop", argv[1]) == 0) &&
            ((strcmp("--host", argv[2]) == 0) || (strcmp("-h", argv[2]) == 0)))
        {
            strcpy(host, argv[3]);
            doNoOp = true;
            argumentError = false;
        }
    }

    // Abort unless arguments were invalid!
    if (argumentError)
    {
        printf("\nInvalid arguments specified!\n");
        return -1;
    }

    if (doNoOp)
    {
        printf("\n"
               "Executing NoOp w/configuration:\n"
               "-------------------------------\n"
@@ -62,6 +97,7 @@ int main(int argc, char** argv)
        {
            printf("\nNoOp operation failed! status=%d\n\n", status);
        }
    }
    
    return status;
}