[ANN] SAFE CLI, Go Library, and Integration Tests - Alpha Release

I just released an early alpha version of my CLI program along with a usable Go library and some integration tests. Links:

Here’s a quick example of how to use the CLI to make a site on any OS (from the README):

go-safeclient mkdir /mysitedir
go-safeclient touch /mysitedir/index.html
echo "Hello World!" | go-safeclient put /mysitedir/index.html
go-safeclient dnsregister mysite www /mysitedir

Quick notes:

  1. There is a small example that shows how to create, write, and read a file in Go
  2. There is an integration test suite that creates a bunch of files and directories to test the API. This might not mean much to most people, but I figure the Maidsafe people will welcome any integration test that tests the network (it already caught some bugs). It doesn’t cover everything, but will one day. See here on how to run it. It takes over 2 minutes for me.
  3. Feedback and participation appreciated. I was kinda worried about putting this level of effort in something like this on such a premature release of the launcher, but hopefully it helps people write apps (Go is really easy to use).

Enjoy!

31 Likes

@cretz even though I am not technical enough to understand or use them fully, the numerous contributions that you have provided lately are a pleasure to see and a real gift for the project :smiley:
Looking forward to your next moves !

9 Likes

From your example you touch the file (create it)
Then you write “Hello World” to the file.

Is the touch necessary? In linux it would not be, but is that something the SAFE api requires? Or would simply writing to the put method work just as well?

1 Like

Thanks! Not gonna lie, my motives are partially selfish, I want the platform to succeed because I have other app ideas :slight_smile:

7 Likes

Let’s try!

echo "Hello world!" | go-safeclient put /myfile.txt
2016/03/16 22:27:54 Failed to write file: Server error 500: {"errorCode":-1503,"description":"InvalidPath"}

Yes, I am afraid you have to create then modify. This is the difference between /nfs/file/:rootPath/:filePath and https://maidsafe.readme.io/docs/nfs-update-file-content. You can easily just make the code do a create-then-modify and make it just look like a create normal create file (this is what the demo app does). In retrospect I probably shouldn’t have called it touch which implies it can also be done on an already existing file (which is why I have that this-is-not-posix disclaimer at the top of the repo).

3 Likes

Gotta. And thanks for the details.

1 Like

IF this did take on a more posix feel like GitHub - uutils/coreutils: Cross-platform Rust rewrite of the GNU coreutils Then perhaps we could achive some really nice cross platform utils packages. Anyway superb work. I think @Viv will make a call but it would seem safe_examples should maybe take on a structure like

Node         -> Dns
             -> Nfs
Go           -> Dns
             -> Nfs 
python       -> Dns
             -> Nfs 
Rust ..... etc. 

We could use submodules to link all of these as folks do them, Making a really nice examples structure that can be tied to the API docs etc. and get as muhc feedback as possible in many languages.

Superb work

4 Likes

Thanks!

I agree. One of my goals here was to expose the low level calls for what they were at a primitive level so that people leveraging the CLI calls in some bash script or something would know what’s happening. I could abstract higher, but I can just picture some “creating files with data is not atomic” bug. But yes, abstraction will be required for usefulness.

I suggest making a repo called awesome-safe in the same vein as everything on GitHub - sindresorhus/awesome: 😎 Awesome lists about all kinds of interesting topics (e.g. GitHub - ipfs/awesome-ipfs: Community list of awesome projects, apps, tools, and services related to IPFS.).

2 Likes

To solve that, you provide the lowest level and some appropriate higher level ones.

I just spent the last 3 days doing similar with another totally unrelated (to SAFE&crypto) system’s api calls and used bash script to prove they functioned correctly.

I am glad you are doing this for SAFE. You certainly have my thanks.

3 Likes

Nice work!

Minor issue - on Ubuntu, the conf.json was created with unusual permissions, which meant it failed to re-auth the next time I executed the command. I ‘chmod 644 conf.json’ and it resolved it.

I played with this and managed to touch, put, fetch, ls all with ease!

2 Likes

Thanks! I purposefully created it with 0600 private because of its sensitive nature (ref go-safeclient/root.go at master · cretz/go-safeclient · GitHub) but if it’s breaking I’ll look into it. Again, thank you very much for trying it.

I just deleted conf.json and allowed it to be recreated to confirm the original permissions and they are o=x,g=wx (—x-wx—), so it looks like something odd is going on there.

(EDIT: To confirm, ‘chmod 600’ fixes it too.)

Stupid octals. I have fixed this and tagged a new alpha release at Release 0.1.0 Alpha 2 · cretz/go-safeclient · GitHub. I included the Linux binary in the release this time so you don’t have to build it by hand. I am also updating the main topic to point to the new release. Thanks for the bug report.

5 Likes

Oh that’s cool, it actually worked!

I notice that:

  1. You don’t need the quotation marks.

  2. I’m overwriting whatever someone else might have put at http://mysite.safenet (surely there have been others doing this)

How do I use it to create a subdirectory on my own domain?

go-safeclient.exe mkdir /bluebird/public/lalala

or

go-safeclient.exe mkdir /bluebird/lalala

give an error:
Failed to create dir: Server error 500: {“errorCode”:-1502," description":“FfiError::PathNotFound”}

What am I actually looking at? Where is mysitedir and why don’t I see other folders, created by other people?

Because those directories are not shared. Therefore they are specific to you and the app combined. There are options on the command to make them shared. Granted it is “public” (not to be confused with shared) so I believe that is why DNS can see it. I have to defer to maidsafe to explain private/public vs shared/not-shared. I also have to defer to them on the inevitable question: “if ls can only see things made per app, why can DNS see the same things created by another app?”

1 Like

I had to google what a CLI is. It may be worth mentioning in full words what this is in the title to save others :slight_smile:

1 Like

Solid. Basic tools like this form the backbone of the Safenet!

2 Likes

whoooot - how did i miss that :frowning: … just saw it in @happybeing 's working apps topic =)

Just want to mention! This is a marvellous day in my safe world :slight_smile: discovered 3 new apps on a single day

thank you very very much @cretz

2 Likes

Trying to add a service to an existing name with the Linux client, i get:

    $ go-safeclient dnsaddservice bluebird1 test2 /testdir
    2016/05/29 17:39:05 Unable to add service: Server error 400: {"errorCode": 1502,"description":"FfiError::PathNotFound"} 

On the other hand, if I create a new name then it shows up in demo app, which I get a childish delight from. :slight_smile:

What would be really cool would be a command-line version of the launcher.

1 Like