bnb-chain / greenfield-cmd

support cmd tool for Greenfield
GNU Lesser General Public License v3.0
28 stars 12 forks source link

refactor: improve list , delete cmd and the return format #72

Closed flywukong closed 1 year ago

flywukong commented 1 year ago

Description

improve cmd tools by the follow inspect: 1) support --recursive flag to support list or delete folder in a recursive way 2) Optimized the "object ls" and "object rm" method by using the page pagination method to support the list of a large number of files 3) Optimize the return format of cmd such as list, delete, put and so on, closer to the "aws cli" style 4) Removed the "create folder" command, using the same method as "aws cli" to support folder operations by "object put" or "rm --recursive" 5) update dependency to solve "list objects" and "list bucket" issue

Rationale

improve greenfield cmd

Example

1) improve "object ls " to support with the setting of prefix and support recursive way , the logic is the same as "aws cli" tool.

wayen@qa-test % ./gnfd-cmd  object ls --recursive gnfd://test009
2023-08-04 10:51:40              65 file1
2023-08-04 15:57:13             501 file2
2023-08-04 11:36:51              65 folder2/
2023-08-04 11:46:19              65 folder4/
2023-08-04 18:14:30              65 folder4/folder11/dsx1
2023-08-04 18:06:43              65 folder4/sxx
2023-08-04 18:13:58              65 folder4/sxx2

wayen@qa-test % ./gnfd-cmd  object ls  gnfd://test009
2023-08-04 10:51:40              65 file1
2023-08-04 15:57:13             501 file2
                                PRE folder2/
                                PRE folder4/

wayen@ qa-test % ./gnfd-cmd  object ls  gnfd://test009/file
Please enter a passphrase now:
2023-08-04 10:51:40              65 file1
2023-08-04 15:57:13             501 file2

2) support delete folder and create folder with "object put" or "object rm "

[wayen@testnet-test % ./gnfd-cmd object put gnfd://testx1/folder3/
object folder3/ created on chain
transaction hash: 82FF5087B440D997371408DDF0919D5F21C0BFEDC1966504EDD188407AC63E53

wayen@c02fvfsdmd6m testnet-test % ./gnfd-cmd object ls --recursive gnfd://testx1
2023-08-08 14:11:31              65 folder1/klds1
2023-08-08 14:11:53              65 folder1/klds2
2023-08-08 14:13:06               0 folder3/

wayen@ testnet-test % ./gnfd-cmd object rm --recursive gnfd://testx1/folder1
delete: folder1/klds1
delete: folder1/klds2

delete all the objects in bucket

wayen@ testnet-test % ./gnfd-cmd object ls --recursive gnfd://testx1
2023-08-08 14:43:46              65 ds11
2023-08-08 14:42:02               0 folder3/
2023-08-08 14:42:21              65 folder3/dxs11
2023-08-08 14:42:43              65 folder3/dxs12
2023-08-08 14:43:10              65 key.txt
wayen@ testnet-test % ./gnfd-cmd object rm --recursive gnfd://testx1
delete: ds11
delete: folder3/
delete: folder3/dxs11
delete: folder3/dxs12
delete: key.txt

3) improve cmd return format

wayen@testnet-test % ./gnfd-cmd sp ls
name         operator address                           endpoint                              status
bnbchain-sp1 0xCE5FC4786fbbFEf97841B2CB3c3F1C3A03C3ba13 https://gnfd-testnet-sp1.bnbchain.org IN_SERVICE
bnbchain-sp2 0x8A26E3752031A08cBf791f45f09dee66579a8A9d https://gnfd-testnet-sp2.bnbchain.org IN_SERVICE
bnbchain-sp3 0x9E49844DB47f07c7059131F9635fa56Cb3CE8c57 https://gnfd-testnet-sp3.bnbchain.org IN_SERVICE
bnbchain-sp4 0xcf8351B881D578DaCEeb7fc55B0b4fB0971070f6 https://gnfd-testnet-sp4.bnbchain.org IN_SERVICE
nodereal-sp1 0xb27457Bb90C902B690c276A470A5fA393FD7BD4F https://gnfd-testnet-sp1.nodereal.io  IN_SERVICE
nodereal-sp2 0x7df63379274A445AA4eFa6cc2bFb574B41B7D859 https://gnfd-testnet-sp2.nodereal.io  IN_SERVICE
nodereal-sp3 0x3ae3A9670D85B7F80aF823Ac2Ca72415d0975D0b https://gnfd-testnet-sp3.nodereal.io  IN_SERVICE
HashQuark    0xDA8EC34bBF3641Dc966e20B8aCB6f51b0bd16Bc2 https://gnfd-testnet-sp.epotter-qa.io IN_SERVICE

Changes

Notable changes: