Skip to content

Conversation

@qcjames53
Copy link
Contributor

Modified the replaced_by string on fields to a replaced_by_path relative path to another field. This allows for displaying the exact translation of the new path to stderr and can better handle label name changes in the future.

From the docs:
A field may be 'replaced by' another field using :replaced_by_path => ["relative","path","to","new","field"]. Use "!p" to indicate the parent field/list/collection and other strings to indicate the id of child field/list/collections. This will mark the field as deprecated and print a similar warning message to stderr whenever the field is displayed.

For example, to replace 'Foo/Bar/Old field' with 'Foo/Baz/New field', do the following:

field :old_fld, _("Old Field"), Fields::Field, :sets => ['ALL'], :replaced_by => ["!p","!p","baz","new_fld"]

Example output:

$ hammer foo info --fields "Foo/Bar/Old field"
Warning: Field 'Foo/Bar/Old field' is deprecated. Consider using 'Foo/Baz/New field' instead.
Foo:
  Bar:
    Old field: data

@qcjames53
Copy link
Contributor Author

Closing PR as these changes are no longer considered the best approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant