From 1a2256f98540c0b2587bac26a4f9f9ad35638ae1 Mon Sep 17 00:00:00 2001 From: 1998-felix Date: Fri, 3 May 2024 17:51:05 +0300 Subject: [PATCH] feat: add options command, example with coap.me Signed-off-by: 1998-felix --- examples/coapme/test.sh | 40 ++++++++++++++++++++++++++++++++++++++++ go.mod | 6 ++++++ 2 files changed, 46 insertions(+) create mode 100755 examples/coapme/test.sh diff --git a/examples/coapme/test.sh b/examples/coapme/test.sh new file mode 100755 index 0000000..e7bf53f --- /dev/null +++ b/examples/coapme/test.sh @@ -0,0 +1,40 @@ +host="coap.me" +port="5683" +testPath="/test" +largePath="/large" +etagPath="/etag" +payload="Hello world from absmach/coap-cli" + +#Get +echo "Sending GET request to $host:$port$testPath" +coap-cli get $testPath -H $host -p $port +sleep 1 + +#Get with blockwise transfer +echo "Sending GET request with blockwise transfer to $host:$port$testPath" +coap-cli get $largePath -H $host -p $port +sleep 1 + +#Post +echo "Sending POST request to $host:$port$testPath" +coap-cli post $testPath -H $host -p $port -d $payload +sleep 1 + +#Post with content format +echo "Sending POST request with content format to $host:$port$testPath" +coap-cli post $testPath -H $host -p $port -d $payload -c 50 +sleep 1 + +#Post with authentication +echo "Sending POST request with authentication to $host:$port$testPath" +coap-cli post $testPath -H $host -p $port -d $payload --auth "test" +sleep 1 + +#Put +echo "Sending PUT request to $host:$port$testPath" +coap-cli put $testPath -H $host -p $port -d $payload +sleep 1 + +#Delete +echo "Sending DELETE request to $host:$port$testPath" +coap-cli delete $testPath -H $host -p $port diff --git a/go.mod b/go.mod index 340c1c2..ada77fe 100644 --- a/go.mod +++ b/go.mod @@ -8,8 +8,14 @@ require ( github.com/spf13/cobra v1.8.0 ) +require ( + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect +) + require ( github.com/dsnet/golib/memfile v1.0.0 // indirect + github.com/fatih/color v1.16.0 github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/inconshreveable/mousetrap v1.1.0 // indirect