generated from dnnrly/goclitem
-
-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from dnnrly/feature/headers
Add support for common HTTP headers
- Loading branch information
Showing
7 changed files
with
1,425 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
Copyright © 2020 NAME HERE <EMAIL ADDRESS> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"github.com/dnnrly/httpref" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// headersCmd represents the headers command | ||
var headersCmd = &cobra.Command{ | ||
Use: "headers", | ||
Aliases: []string{"header"}, | ||
Short: "References for common HTTP headers", | ||
Long: `This displays useful information related to HTTP. | ||
Most of the content comes from the Mozilla developer documentation (https://developer.mozilla.org/en-US/docs/Web/HTTP) and is copyright Mozilla and individual contributors. See https://developer.mozilla.org/en-US/docs/MDN/About#Copyrights_and_licenses for details.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
results := httpref.Headers | ||
|
||
if len(args) == 0 { | ||
results = results.Titles() | ||
} else { | ||
results = results.ByName(args[0]) | ||
} | ||
|
||
printResults(results) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(headersCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
Copyright © 2020 NAME HERE <EMAIL ADDRESS> | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
package cmd | ||
|
||
import ( | ||
"github.com/dnnrly/httpref" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// statusCmd represents the status command | ||
var statusCmd = &cobra.Command{ | ||
Use: "status [filter]", | ||
Short: "References for HTTP status codes", | ||
Long: `This displays useful information related to HTTP. | ||
Most of the content comes from the Mozilla developer documentation (https://developer.mozilla.org/en-US/docs/Web/HTTP) and is copyright Mozilla and individual contributors. See https://developer.mozilla.org/en-US/docs/MDN/About#Copyrights_and_licenses for details.`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
results := httpref.Statuses | ||
|
||
if len(args) == 0 { | ||
results = results.Titles() | ||
} else { | ||
results = results.ByName(args[0]) | ||
} | ||
|
||
printResults(results) | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(statusCmd) | ||
} |
Oops, something went wrong.